zentiff 0.1.0

TIFF decoding and encoding wrapper with zenpixels integration
Documentation

zentiff CI crates.io lib.rs docs.rs License

TIFF decoding and encoding with zenpixels integration. Wraps the tiff crate, providing a pixel-buffer-oriented API that plugs into the zen* codec ecosystem.

#![forbid(unsafe_code)]

Quick start

use zentiff::{decode, probe, encode, TiffDecodeConfig, TiffEncodeConfig};
use enough::Unstoppable;

// Decode
let data: &[u8] = &[]; // your TIFF bytes
let output = decode(data, &TiffDecodeConfig::default(), &Unstoppable)?;
println!("{}x{}", output.info.width, output.info.height);

// Encode
let encoded = encode(&output.pixels.as_slice(), &TiffEncodeConfig::default(), &Unstoppable)?;
# Ok::<(), whereat::At<zentiff::TiffError>>(())

Decode support

All color types and sample depths handled by the tiff crate:

Source format Output
Gray u8/u16 Gray8 / Gray16
Gray float GrayF32
GrayAlpha u8/u16/float GrayAlpha8/16/F32
RGB / YCbCr / Lab u8/u16/float RGB8/16/F32
RGBA u8/u16/float RGBA8/16/F32
Palette RGB8 (requires _palette feature, see below)
CMYK / CMYKA RGBA8/16 (converted)

Higher-depth integers (u32/u64/i8-i64) are widened to the next supported depth. Sub-byte samples (1/2/4/6-bit) are unpacked and scaled to 0-255.

Encode support

Format Depths
Gray u8, u16, f32
GrayAlpha u8, u16, f32 (expanded to RGBA)
RGB u8, u16, f32
RGBA u8, u16, f32

Compression options: LZW (default), Deflate, PackBits, or uncompressed. Horizontal prediction for improved compression ratios. Standard and BigTIFF formats.

Metadata

Extracts ICC profiles, EXIF (re-serialized from sub-IFD), XMP, IPTC, resolution (with cm→inch conversion), orientation, compression method, photometric interpretation, page count, and page name.

zencodec integration

With the zencodec feature, zentiff implements both zencodec::decode::DecoderConfig and zencodec::encode::EncoderConfig for codec-agnostic image pipelines.

Resource limits, cooperative cancellation, and decode policy (metadata suppression) are all supported through the zencodec trait flow.

Features

Feature Default Description
std Yes Standard library support (required for I/O)
deflate Yes DEFLATE/zlib compression
lzw Yes LZW compression
zencodec No zencodec encode/decode trait integration
fax No CCITT fax compression (Group 3/4)
jpeg No JPEG-in-TIFF compression
webp No WebP-in-TIFF compression
zstd No Zstandard compression
all-codecs No Enables all compression codecs
_palette No Palette TIFF decode (blocked on tiff 0.12, see below)

Known issues

These are upstream limitations in the tiff crate (0.11.x) that affect zentiff:

  • Palette TIFF decode disabled. The tiff crate's color_map() API landed on git main but hasn't been released yet. Palette TIFFs return Unsupported until tiff 0.12 ships. The _palette feature flag exists for forward compatibility but doesn't work with tiff 0.11.x from crates.io.

  • Chroma-subsampled YCbCr not supported. The tiff crate rejects YCbCr data with chroma subsampling (anything other than 1:1) unless JPEG-compressed. There is no upsampling routine in the decoder. This means non-JPEG YCbCr TIFFs with 4:2:2 or 4:2:0 subsampling will fail to decode.

  • Planar TIFF workaround. Decoder::read_image() only reads the first plane for planar TIFFs. zentiff works around this by using read_image_to_buffer() and interleaving planes manually. This workaround is tested and functional.

  • Pending decoder API migration. The upstream tiff crate is moving from Decoder::new() to Decoder::open() + next_image(). zentiff will migrate when tiff 0.12 releases with the new API.

  • Multi-page decode is probe-only. Page count is reported in TiffInfo, but the decode API only reads the first page. Multi-page decode would require exposing page selection (tracked for a future release).

Dependencies

All runtime dependencies are permissive (MIT, Apache-2.0, Zlib, BSD-2-Clause). No copyleft in the dependency tree.

Image tech I maintain

State of the art codecs* zenjpeg · zenpng · zenwebp · zengif · zenavif (rav1d-safe · zenrav1e · zenavif-parse · zenavif-serialize) · zenjxl (jxl-encoder · zenjxl-decoder) · zentiff · zenbitmaps · heic · zenraw · zenpdf · ultrahdr · mozjpeg-rs · webpx
Compression zenflate · zenzop
Processing zenresize · zenfilters · zenquant · zenblend
Metrics zensim · fast-ssim2 · butteraugli · resamplescope-rs · codec-eval · codec-corpus
Pixel types & color zenpixels · zenpixels-convert · linear-srgb · garb
Pipeline zenpipe · zencodec · zencodecs · zenlayout · zennode
ImageResizer ImageResizer (C#) — 24M+ NuGet downloads across all packages
Imageflow Image optimization engine (Rust) — .NET · node · go — 9M+ NuGet downloads across all packages
Imageflow Server The fast, safe image server (Rust+C#) — 552K+ NuGet downloads, deployed by Fortune 500s and major brands

* as of 2026

General Rust awesomeness

archmage · magetypes · enough · whereat · zenbench · cargo-copter

And other projects · GitHub @imazen · GitHub @lilith · lib.rs/~lilith · NuGet (over 30 million downloads / 87 packages)

License

Dual-licensed: AGPL-3.0 or commercial.

I've maintained and developed open-source image server software — and the 40+ library ecosystem it depends on — full-time since 2011. Fifteen years of continual maintenance, backwards compatibility, support, and the (very rare) security patch. That kind of stability requires sustainable funding, and dual-licensing is how we make it work without venture capital or rug-pulls. Support sustainable and secure software; swap patch tuesday for patch leap-year.

Our open-source products

Your options:

  • Startup license — $1 if your company has under $1M revenue and fewer than 5 employees. Get a key →
  • Commercial subscription — Governed by the Imazen Site-wide Subscription License v1.1 or later. Apache 2.0-like terms, no source-sharing requirement. Sliding scale by company size. Pricing & 60-day free trial →
  • AGPL v3 — Free and open. Share your source if you distribute.

For commercial licensing details, contact support@imazen.io or visit imazen.io/pricing.

AI-Generated Code Notice

Developed with Claude (Anthropic). Not all code manually reviewed. Review critical paths before production use.