Field notes/Mediarusty_tiffTIFF

rusty_tiff: TIFF and BigTIFF Without libtiff

rusty_tiff is a pure-Rust TIFF and BigTIFF decoder and encoder. G4 decode runs 1.3 to 1.6x faster than libtiff, and malformed files return an error, never a panic.

Signed by M·
Painted archive drawer of stacked photographic plates sliding open under warm lamp light
What is rusty_tiff?

rusty_tiff is a pure-Rust TIFF and BigTIFF decoder and encoder from Remade with Rust. It reads and writes strips and tiles with LZW, Deflate, PackBits, CCITT G3/G4 and JPEG-in-TIFF compression, floats and predictors, multipage files and SubIFDs, and EXIF, ICC and XMP tags. It is Apache-2.0, has no C and no unsafe code, and version 0.1.1 is on crates.io.

Ship it

4 to 6× Faster G4 Decode

than the tiff crate, and 1.3 to 1.6× faster than libtiff, with no C and no unsafe.

Open the rusty_tiff conversion pin →

rusty_tiff is a pure-Rust TIFF and BigTIFF decoder and encoder. Version 0.1.1 decodes CCITT G4 fax images 1.3 to 1.6 times faster than libtiff, ties the tiff crate on uncompressed files, and returns an error on malformed input instead of panicking. It is Apache-2.0 and has no C and no unsafe.

TIFF is the format that never left. Scanners write it, fax servers store it, archives keep it, and DNG raw photos use its structure. That makes a TIFF parser part of the attack surface of every document intake, library digitisation job and photo pipeline that accepts files from outside. rusty_tiff is the Remade with Rust answer: the same format, read and written by memory-safe code.

For the conversion pin and GitHub steps, open the rusty_tiff repo landing. The measurements below come from the 0.1.1 campaign note, which covers all three still-image crates.

What rusty_tiff Covers

Formats and compression

The rusty_tiff decoder and encoder handle classic TIFF and BigTIFF, in strips and in tiles. Compression covers LZW, Deflate, PackBits, CCITT Group 3 and Group 4, and JPEG-in-TIFF. It reads floating-point samples and horizontal predictors, walks multipage files and SubIFDs (the TIFF layer inside DNG), and carries EXIF, ICC and XMP tags through. The decoder is pixel-identical to image-tiff on that crate's test matrix, so moving a reader across does not move a pixel.

Why TIFF has so many compressions

TIFF is a container, not one codec, and each compression scheme came from a different job. CCITT Group 3 and Group 4 are the fax codecs, built for black-and-white pages, and they still dominate scanned documents. LZW and Deflate are lossless and general, common in archival masters. PackBits is a simple run-length scheme that old scanners and printers still emit. JPEG-in-TIFF holds photographic scans at a fraction of the size. A reader that only handles some of these fails on the first file from a different scanner, which is why rusty_tiff decodes and encodes all of them.

Damaged files are the normal case

A TIFF from the outside world is often broken: truncated strips, offsets past the end of the file, tag counts that do not add up. rusty_tiff treats that as ordinary input. Malformed data returns an error, never a panic. On an 18,024-file set of damaged TIFFs, the new release decodes 806 files that both the tiff 0.11 crate and rusty_tiff 0.1.0 refused, plus 128 of the 141 files that tiff decoded but 0.1.0 had refused. No file in the set caused a panic.

Where it lives

The crate ships from the remade_ffmpeg_rs monorepo, beside rusty_image and rusty_icc, and the current release is on crates.io. Add it with cargo add rusty_tiff.

Measured Speed, Latest Release

Decode against tiff and libtiff

All figures come from pinned, interleaved (ABBA) runs, N=20, on the ArtCraft team's harness. CCITT G4 decode is 4 to 6 times faster than the tiff crate and 1.3 to 1.6 times faster than libtiff. On uncompressed files the two Rust readers are level with each other, while libtiff trails by a factor of 1.10 to 1.12. LZW decode was already 1.15 to 1.55 times faster than tiff before its last change, and that last change alone took our own LZW run from 0.24 to 0.12 seconds at 8 bits and from 0.40 to 0.18 seconds at 16 bits.

Encode and instruction counts

PackBits encode is 3.9 to 4.2 times faster than the tiff crate. Under callgrind on 1536 by 1024 crops of a real photo, the new encoder retires 71 percent fewer instructions than 0.1.0 on uncompressed encode, 67 percent fewer on PackBits, 49 percent fewer on LZW and 25 percent fewer on Deflate. Every output is byte-identical to 0.1.0. The campaign note explains where those instructions went.

Who should adopt it first

Teams that ingest scans and faxes, document converters, digital archives, and photo tools that touch DNG. Any service that accepts a TIFF upload from a stranger is running a parser on hostile bytes, and rusty_tiff takes the C out of that step.

Building a Scan Pipeline on rusty_tiff

The stills crates around it

rusty_tiff covers one format well and leaves the rest to siblings. rusty_jpeg and rusty_png handle the two web formats, and rusty_image covers BMP, TGA, ICO, PNM, HDR and QOI. Scans from colour-managed devices usually embed an ICC profile; rusty_tiff carries that tag through, and rusty_icc parses it and converts the pixels into the space you display or print. All four crates ship from remade_ffmpeg_rs, so their versions move together.

From fax page to searchable text

A common job is turning a stack of Group 4 fax pages into text. rusty_tiff walks each page of the multipage file and decodes it to a bilevel bitmap, an OCR engine such as Carmenta reads the text, and the result is stored next to the original. Because a damaged page returns an error instead of crashing the process, one bad file does not stop the batch; log it and move on. RAG Converter runs this kind of local document conversion in the browser, which is only possible when every decoder in the chain compiles to wasm.

Running it without a C toolchain

The same crate builds for a laptop, a server and wasm, so an intake service needs no libtiff package on any of them and no C compiler in CI. That is the property the NIST SSDF points at when it asks teams to reduce memory-unsafe code on paths that take outside input. Services built this way can be hosted on mata.network or on a single machine at home. For why the house rebuilds file-format parsers at all, read The Importance of Remade With Rust, and if the scans belong to a team, keep the extracted text beside the user in SpaceDB, with Deputy checking the dependency graph before you ship.

FAQ

Quick answers for builders evaluating this technology.

What does rusty_tiff replace?

It replaces libtiff and the tiff crate on paths that read or write TIFF. Its decoder is pixel-identical to image-tiff on that crate's test matrix.

How fast is rusty_tiff 0.1.1?

On pinned, interleaved runs, CCITT G4 decode is 4 to 6 times faster than the tiff crate and 1.3 to 1.6 times faster than libtiff. Uncompressed decode ties the tiff crate and beats libtiff 1.10 to 1.12 times. PackBits encode is 3.9 to 4.2 times faster than the tiff crate.

What happens when rusty_tiff opens a damaged TIFF?

Malformed input returns an error and never panics. On an 18,024-file set of damaged TIFFs, version 0.1.1 decodes 806 files that both the tiff crate and rusty_tiff 0.1.0 refused, and no file caused a panic.

Where is the rusty_tiff source?

rusty_tiff lives in the remade_ffmpeg_rs monorepo under crates/rusty_tiff on GitHub, beside rusty_image and rusty_icc. Add it with cargo add rusty_tiff.

Does rusty_tiff handle the colour profile inside a TIFF?

It reads and writes the ICC tag and passes it through. Converting pixels with that profile is the job of the sibling crate rusty_icc, which parses ICC v2 and v4 and transforms between colour spaces.