otf-pixels-compress
DEFLATE, zlib, LZW and checksums, in safe Rust
An Open Tech Foundation project
The compression the Pixels codecs share: PNG and TIFF use zlib, GIF and TIFF use LZW. Every decoder takes an output limit, so a decompression bomb is an error.
Use it
use ;
let data = b"hello hello hello hello";
let packed = zlib_compress?;
let unpacked = zlib_decompress?; // refuses more than 1 MiB
assert_eq!;
let checksum = of;
API
| Item | What it does |
|---|---|
zlib_compress, deflate, Level |
Compress, zlib-wrapped or raw, levels 0–9 |
zlib_decompress, inflate_to |
Decompress a whole buffer, up to a byte limit |
ZlibStream, Inflater |
Decompress incrementally, as input arrives |
LzwEncoder, LzwDecoder, BitOrder |
LZW in GIF (LSB-first) or TIFF (MSB-first) order |
Crc32, Adler32 |
The checksums PNG and zlib use |
Output is checked against the reference zlib, both ways.
Part of Pixels
| Crate | Role |
|---|---|
otf-pixels |
The chainable Image API most users want |
otf-pixels-core |
Graph, tiles, scheduler, codec and op traits |
otf-pixels-ops |
Image operations |
otf-pixels-compress |
DEFLATE, zlib, LZW, checksums |
otf-pixels-codec-* |
One crate per format |
License
Apache-2.0 — see LICENSE.