otf-pixels-codec-tiff 0.2.0

TIFF codec for otf-pixels, implemented from scratch.
Documentation

otf-pixels-codec-tiff

TIFF for Pixels, written from scratch

crates.io | Docs | Pixels

An Open Tech Foundation project

Baseline TIFF 6.0 in strips and tiles. A tiled TIFF decodes any region on its own, so a thumbnail of a huge scan reads only the tiles it needs.

[!TIP] Building an app or a server? Use otf-pixels instead: it picks this codec from the file's bytes with its tiff feature.

Use it

Transcode row by row, without holding the image:

use otf_pixels_codec_tiff::{TiffDecoder, TiffEncoder};
use otf_pixels_core::{Decoder, Encoder, Limits};
use otf_pixels_codec_tiff::TiffLayout;

let mut decoder = TiffDecoder::new(std::fs::File::open("scan.tif")?, Limits::default())?;
let descriptor = decoder.descriptor();
let mut encoder = TiffEncoder::new().with_layout(TiffLayout::Tiles { width: 256, height: 256 })?;
let mut out = Vec::new();
encoder.write_header(&descriptor, &mut out)?;
let mut row = vec![0; descriptor.row_bytes()];
for _ in 0..descriptor.height {
    decoder.read_row(&mut row)?;
    encoder.write_row(&row, &mut out)?;
}
encoder.finish(&mut out)?;

Capabilities

Area Support
Decode Both byte orders, strips and tiles, none/LZW/Deflate/PackBits, 1/8/16-bit
Encode Strips or tiles, uncompressed or Deflate
Checked against libtiff, both directions

API

Item What it does
TiffDecoder Decoder, with region access for tiled files
TiffEncoder, TiffLayout Encoder and its strip/tile layout
TiffImage, Directory, tag The format's own structures
TiffCodec, probe Signature detection

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.