otf-pixels-compress 0.2.0

Compression and checksum primitives for otf-pixels codecs.
Documentation
  • Coverage
  • 100%
    20 out of 20 items documented0 out of 4 items with examples
  • Size
  • Source code size: 121.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 918.0 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Open-Tech-Foundation/Pixels
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Thanga-Ganapathy

otf-pixels-compress

DEFLATE, zlib, LZW and checksums, in safe Rust

crates.io | Docs | Pixels

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 otf_pixels_compress::{Crc32, Level, zlib_compress, zlib_decompress};

let data = b"hello hello hello hello";
let packed = zlib_compress(data, Level::new(6)?)?;
let unpacked = zlib_decompress(&packed, 1 << 20)?; // refuses more than 1 MiB
assert_eq!(unpacked, data);
let checksum = Crc32::of(data);

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.