Skip to main content

gamut_tiff/
lib.rs

1//! `gamut-tiff` — TIFF 6.0 (Tagged Image File Format) image encoder and decoder.
2//!
3//! TIFF is a *natively still-image* format: its Image File Directory (IFD) / tag structure **is**
4//! the container, so this crate needs neither
5//! [`gamut_isobmff`](https://crates.io/crates/gamut-isobmff) (AVIF/HEIC) nor
6//! [`gamut_riff`](https://crates.io/crates/gamut-riff) (WebP). That IFD container core — the
7//! byte-order header, field types/values, the IFD chain, and the offset-driven read/write spine —
8//! is the shared [`gamut_ifd`](https://crates.io/crates/gamut-ifd) primitive (also the basis for
9//! EXIF); this crate adds the codec on top and re-exports the structural types from its root so its
10//! public API is unchanged. It further layers on the shared primitives: [`gamut_core`] (traits /
11//! errors), [`gamut_color`] (photometric & pixel formats, incl. palette / CMYK / YCbCr /
12//! CIE L\*a\*b\*), [`gamut_dsp`] (the differencing predictor and the DCT used by JPEG-in-TIFF), and
13//! [`gamut_bitstream`] (LZW and CCITT bit coding).
14//!
15//! The encoder and decoder are reachable through the umbrella crate's `tiff` feature. Everything
16//! is implemented clean-slate from the TIFF 6.0 specification (`references/tiff/tiff6.pdf`,
17//! Adobe/Aldus, Final — June 3 1992) and the BigTIFF extension (`references/tiff/bigtiff.html`)
18//! rather than wrapping libtiff.
19//!
20//! Implementation in progress (see issue #107). The codec layer ([`ifd`] photometric/predictor
21//! semantics, [`writer`] strip/tile/multi-page layout over [`gamut_ifd::write`], [`tags`],
22//! [`compression`]) and the baseline pixel path are in place: [`TiffEncoder`] writes 8-bit
23//! grayscale/RGB/RGBA/CMYK, 1-bit bilevel, and 8-bit palette images (as strips or tiles) —
24//! uncompressed, PackBits, LZW, or (for bilevel) Modified Huffman / Group 4 fax — and
25//! [`TiffDecoder`] reads them back. Encoding takes a typed [`gamut_core::ImageRef`] via the
26//! per-format [`gamut_core::EncodeImage`] impls, and decoding returns a [`gamut_core::ImageBuf`] via
27//! [`gamut_core::DecodeImage`]. Both the classic 32-bit container and
28//! **BigTIFF** (magic `43`, 64-bit offsets, for files past 4 GiB) are written and read: opt into
29//! BigTIFF with [`TiffEncoder::with_big_tiff`], and the decoder detects the variant from the
30//! header. The remaining compression schemes and colour modes land in subsequent phases.
31#![forbid(unsafe_code)]
32
33pub mod compression;
34pub mod decoder;
35pub mod encoder;
36pub mod ifd;
37pub mod palette;
38pub mod tags;
39pub mod writer;
40
41pub use compression::Compression;
42pub use decoder::TiffDecoder;
43pub use encoder::TiffEncoder;
44pub use palette::Palette8;
45// The structural IFD core lives in gamut-ifd; re-export it so gamut-tiff's public API is unchanged.
46pub use gamut_ifd::{ByteOrder, Field, FieldType, Ifd, TiffFile, Value, Variant, read, write};
47pub use ifd::{PhotometricInterpretation, Predictor};
48pub use writer::{write_image, write_image_tiled, write_multipage};