Skip to main content

Crate gamut_tiff

Crate gamut_tiff 

Source
Expand description

gamut-tiff — TIFF 6.0 (Tagged Image File Format) image encoder and decoder.

TIFF is a natively still-image format: its Image File Directory (IFD) / tag structure is the container, so this crate needs neither gamut_isobmff (AVIF/HEIC) nor gamut_riff (WebP). That IFD container core — the byte-order header, field types/values, the IFD chain, and the offset-driven read/write spine — is the shared gamut_ifd primitive (also the basis for EXIF); this crate adds the codec on top and re-exports the structural types from its root so its public API is unchanged. It further layers on the shared primitives: gamut_core (traits / errors), gamut_color (photometric & pixel formats, incl. palette / CMYK / YCbCr / CIE L*a*b*), gamut_dsp (the differencing predictor and the DCT used by JPEG-in-TIFF), and gamut_bitstream (LZW and CCITT bit coding).

The encoder and decoder are reachable through the umbrella crate’s tiff feature. Everything is implemented clean-slate from the TIFF 6.0 specification (references/tiff/tiff6.pdf, Adobe/Aldus, Final — June 3 1992) and the BigTIFF extension (references/tiff/bigtiff.html) rather than wrapping libtiff.

Implementation in progress (see issue #107). The codec layer (ifd photometric/predictor semantics, writer strip/tile/multi-page layout over gamut_ifd::write, tags, compression) and the baseline pixel path are in place: TiffEncoder writes 8-bit grayscale/RGB/RGBA/CMYK, 1-bit bilevel, and 8-bit palette images (as strips or tiles) — uncompressed, PackBits, LZW, or (for bilevel) Modified Huffman / Group 4 fax — and TiffDecoder reads them back. Encoding takes a typed gamut_core::ImageRef via the per-format gamut_core::EncodeImage impls, and decoding returns a gamut_core::ImageBuf via gamut_core::DecodeImage. Both the classic 32-bit container and BigTIFF (magic 43, 64-bit offsets, for files past 4 GiB) are written and read: opt into BigTIFF with TiffEncoder::with_big_tiff, and the decoder detects the variant from the header. The remaining compression schemes and colour modes land in subsequent phases.

Re-exports§

pub use compression::Compression;
pub use decoder::TiffDecoder;
pub use encoder::TiffEncoder;
pub use palette::Palette8;
pub use ifd::PhotometricInterpretation;
pub use ifd::Predictor;
pub use writer::write_image;
pub use writer::write_image_tiled;
pub use writer::write_multipage;

Modules§

compression
TIFF compression schemes, selected by the Compression tag (259).
decoder
The TIFF decoder.
encoder
The TIFF encoder.
ifd
Codec-specific interpretations of two IFD tag values: the photometric interpretation and the prediction scheme.
palette
The 256-entry RGB colour table for palette (indexed-colour) TIFF images.
tags
TIFF tag numbers — the 2-byte Tag field of an IFD entry.
writer
Codec-level serialisation: laying image (strip/tile) data out around an IFD.

Structs§

Field
One field (entry) of an Image File Directory: a tag and its value.
Ifd
A parsed Image File Directory — one node in the IFD chain (a TIFF page, or an EXIF/GPS/Interop sub-directory).
TiffFile
A parsed TIFF/IFD stream: its byte order, container variant, and the chain of Image File Directories.

Enums§

ByteOrder
Byte order of a TIFF stream, named by the two-byte order mark at the start of the header.
FieldType
The type of a tag’s value, stored as the 2-byte Type of an IFD entry (TIFF 6.0 §2).
Value
The decoded value(s) of one IFD entry, one variant per crate::FieldType.
Variant
Which variant of the TIFF container a stream uses, distinguished by the header magic number.

Functions§

read
Parses a TIFF/IFD stream: the header followed by the whole IFD chain.
write
Serialises a TIFF/IFD stream (header + IFD chain + out-of-line value pool) to bytes.