ZMat: a fast compression/decompr​ession lib for MATALB/Octave

ZMat: A MATLAB/Octave toolbox for zlib/gzip/lzma/lz4/zstd/blosc2 memory compression and base64 encoding

https://neurojson.org/wiki/index.cgi?keywords=registration&tool=zmat&ref=mathworks

You are now following this Submission

ZMat 1.0.0 — "Foxy the Fantastic Mr. Fox"
Release date: 2026-04-15
Download
  • Please download zmat by filling out a brief registration form
  • The pre-compiled Octave mex file can only be used with Octave 10+ on Windows and MacOS (on Linux, the Octave mex file supports all Octave versions). The MATLAB mex files can run across a wide range of MATLAB versions.
Highlights
ZMat reaches its first stable release after seven years of development. This release adds a Python binding, updates all bundled compression libraries to their latest versions, and fixes long-standing memory and safety issues in the core C library.
New Features
  • Python binding pip install zmat provides compress, decompress, encode,decode, and a low-level zmat interface; supports all compression methods(zlib, gzip, lzma, lzip, lz4, lz4hc, zstd, blosc2 variants, base64)
  • NumPy array round-trip compress(arr, info=True) returns an info dict;decompress(data, info=info) restores the original dtype, shape, and memory order(mirrors the MATLAB [ss,info]=zmat(arr) / zmat(ss,info) pattern)
  • Octave 10+ compatibility — special matrix types (diagonal, permutation, etc.)are now handled correctly
  • Apple Silicon support — the blosc2 backend now automatically detects SSE2availability on Apple Silicon (M-series) Macs
  • New Linux MEX binaries — pre-compiled MEX files for Linux are now includedin the private folder alongside the existing macOS and Windows binaries
  • macOS .mex extension is now recognized so packages built against newerOctave run on older releases as well
  • Project webpage https://neurojson.org/zmat
Bug Fixes
  • Fixed safety, memory, and efficiency issues throughout zmatlib.c
  • Fixed memory leaks in easylzma (lloyd/easylzma#4, lloyd/easylzma#7, closes #11)
  • Fixed missing header file causing build failures
Build & CI
  • Static linking hardened for macOS (gcc-12) and Linux
  • CI runners updated; added Ubuntu 24.04 and Apple Silicon (arm64) targets
  • Windows MEX and Python wheel builds fixed for MSYS2/MinGW toolchain
Acknowledgement
AI coding assistant Claude has been used in the development of this release.
Quick StartMATLAB / Octave
% Compress and decompress a numeric array (restoring size and type)
orig = single(rand(5));
[compressed, info] = zmat(orig, 1, 'lzma');
restored = zmat(compressed, info);
% Base64 encode and decode a string
encoded = zmat('zmat toolbox', 1, 'base64');
decoded = char(zmat(encoded, 0, 'base64'));
Python Examples
import numpy as np
import zmat
# Compress and decompress bytes
data = b"hello zmat"
compressed = zmat.compress(data, method='zlib')
restored = zmat.decompress(compressed, method='zlib')
# NumPy array round-trip (preserves dtype, shape, memory order)
arr = np.random.rand(4, 5).astype(np.float32)
compressed, info = zmat.compress(arr, method='lz4', info=True)
restored = zmat.decompress(compressed, info=info)
# Base64 encoding
encoded = zmat.encode(b"zmat toolbox", method='base64')
decoded = zmat.decode(encoded, method='base64')
C Examples
#include "zmatlib.h"
#include <string.h>
#include <stdlib.h>
int main(void) {
const char *input = "hello zmat";
unsigned char *compressed = NULL, *decompressed = NULL;
size_t complen = 0, decomplen = 0;
int status = 0;
union TZMatFlags flags = {1}; /* 1 = compress */
/* compress */
zmat_run(strlen(input), (unsigned char *)input,
&complen, &compressed, zmZlib, &status, flags.iscompress);
/* decompress */
flags.iscompress = 0;
zmat_run(complen, compressed,
&decomplen, &decompressed, zmZlib, &status, flags.iscompress);
free(compressed);
free(decompressed);
return 0;
}
Link with: -lzmat -lz -lpthread
Full Changelog
2026-04-15 [1954707] [mex] add Linux mex binaries
2026-04-15 [1558336] [doc] bump version to 1.0, add webpage
2026-04-12 [4310bb1] [macos] allow .mex for octave run older octave
2026-04-11 [5e079a0] [deploy] macos build still hardcode liboctmex full path
2026-04-11 [42518ff] [deploy] remove absolute path to liboctmex.1 on mac
2026-04-11 [41812bb] [ci] statically link gcc on macos, python build show dylib
2026-04-11 [03e0efc] [test] print benchmark output
2026-04-10 [c1eb247] [deploy] build zmat with static gcc
2026-04-10 [9fa6f02] [ci] fix windows python build
2026-04-10 [343e4fb] [bug] add missing header file
2026-04-10 [b993b31] [blosc2] update blosc2 to 2.23.1, zstd to 1.5.7
2026-04-10 [92fa19c] [miniz] update miniz to v3.1.1
2026-04-10 [99d1ddb] [lz4] update lz4 to 1.10.0
2026-04-10 [2c40056] [mex] update linux mex files
2026-03-07 [aea6ad4] [ci] bump python version to 0.9.10 to use latest package
2026-03-07 [6ad3773] [ci] add the missing README, update setup.py to use manylinux
2026-03-07 [4f85fba] [doc] add README for python module
2026-03-07 [f05e962] [feat] support special matrices in octave 10+
2026-03-07 [b440935] [bug] fix various python module building issues
2026-03-07 [9dde248] [feat] add python binding
2026-03-07 [a3e9ddb] [ci] fix MW_MINGW64_LOC again
2026-03-06 [baeccf5] [blosc] automatically detect sse2 on apple silicon
2026-03-05 [a986c56] fix safety, memory, and efficiency issues throughout zmatlib.c
2025-09-21 [1b2cb0f] [ci] update all retired runners
2025-01-18 [6f92b49] [feat] allow to build with miniz without lzma
2024-09-14 [c6a6ce1] [ci] disable upx on macos
2024-08-18 [26b1147] [example] revert sample code back to zlib from lzma test
2024-08-18 [7c3b09b] [deploy] update all build-in mex files after fixing #11
2024-08-18 [ca52abd] [ci] fix github macos-12 runner gcc version
2024-08-18 [66c8e88] [bug] fix memory leakage lloyd/easylzma#4 and lloyd/easylzma#7, close #11
2024-07-18 [d756c37] [ci] debug ubuntu 24.04 octave-dev installation
2024-07-18 [6149af3] [ci] add ubuntu 24.04
2024-06-14 [980b445] [mac] add arm64 apple silicon precompiled mex files
2024-03-30 [b810d29] [package] remove cmake cache file found by debian packaging

Cite As

Qianqian Fang (2026). ZMat: a fast compression/decompression lib for MATALB/Octave (https://github.com/NeuroJSON/zmat), GitHub. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with R2008a and later releases

Platform Compatibility

  • Windows
  • macOS
  • Linux

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes Action
1.0.0

-New Python Binding (https://pypi.org/project/zmat)
-Bug fixes: memory leak,buffer safety
-Octave 10+ support
-Update miniz(3.1.1) ,lz4(1.10.0), zstd(1.5.7), blosc2(2.23.1)
-Optimized using Claude

0.9.9.1

Update tags, add registration link https://neurojson.org/wiki/index.cgi?keywords=registration&tool=zmat&ref=mathworks

0.9.9

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.