Skip to main content

Crate openreadout_tiff

Crate openreadout_tiff 

Source
Expand description

Clean-room reader for the TIFF family.

Container: TIFF 6.0 and BigTIFF (open specifications). Conventions detected from tags, in priority order: OME-TIFF (OME-XML in ImageDescription, multi-file sets, BinaryOnly and *.companion.ome), Zeiss LSM, MetaMorph STK, Aperio SVS, Hamamatsu NDPI, PerkinElmer QPTIFF, MetaMorph MetaSeries, ImageJ hyperstacks, Micro-Manager, and plain TIFF; Nikon NIS-Elements TIFF exports are grouped with their sibling files. A MetaMorph .nd file opens the multi-stage, multi-wavelength time series of TIFF/STK files it names.

Layout and vocabulary: docs/formats/tiff.md. Provenance: docs/provenance/tiff.md.

§Example

Every reader implements openreadout_core::FormatReader: descriptor says what it reads, sniff recognises a file from its first bytes, and open returns a openreadout_core::Dataset with a header-only info() summary and lazy data access.

use openreadout_core::FormatReader;
use openreadout_tiff::TiffReader;

let format = TiffReader.descriptor();
assert_eq!(format.id, openreadout_tiff::FORMAT_ID);
println!("{} ({}): .{}", format.name, format.family, format.extensions.join(", ."));

Reading a file:

use std::path::Path;

use openreadout_core::{FormatReader, PlaneIndex};
use openreadout_tiff::TiffReader;

let mut dataset = TiffReader.open(Path::new("stack.ome.tiff"))?;
let info = dataset.info()?; // headers only: fast even on multi-gigabyte files
for image in &info.images {
    println!(
        "image {}: {} x {} px, {} channel(s), {} plane(s)",
        image.index, image.size_x, image.size_y, image.size_c, image.plane_count
    );
}
// Pixels are read one plane at a time: image 0, channel 0, first Z slice, first time point.
let plane = dataset.read_plane(0, PlaneIndex { c: 0, z: 0, t: 0 })?;
assert_eq!(plane.data.len(), plane.expected_len());

Applications that accept any instrument file usually register every reader in an openreadout_core::Registry and let it detect the format; that is what the openreadout command-line tool does.

§API stability

The supported API is what this page documents. The parser modules are public only so that tests and fuzz targets can reach them: they are hidden from this documentation and may change in any release.

Structs§

TiffReader
The TIFF-family reader.

Constants§

EXTENSIONS
Extensions of the TIFF family (lowercase, without the dot).
FORMAT_ID
Format id used on the command line and in JSON.