Expand description
Crate-agnostic TIFF structure walk for structural inventories.
Shared by zentiff and zenraw; each supplies its decoder rules.
The walk parses a TIFF header, every IFD reachable from the IFD
chain and from pointer entries, out-of-line values and the extents
(strips, tiles, free space, JPEG streams) the directories reference. A
crate supplies Rules saying what its decode path does with each piece;
the walk never decodes pixels.
TIFF parts can interleave in any order, so a TIFF’s parts are siblings in
file order: header, IFDs (each with one child Field per entry),
out-of-line values (Field, same tag as their entry) and extents.
Where parts overlap, each byte takes the strongest fate among the parts
covering it (Placed); the others are split around it, with a note in
both details. Nothing overlapping is ever emitted.
Structs§
- Cand
- A part before overlap resolution, with its own children.
- Chunk
Geom - The decoded layout of one strip or tile.
- Chunk
Use - How much of one strip or tile the decoder reads.
- Entry
- One IFD entry.
- Extent
Rule - An offset tag with the lengths of the extents it locates.
- Fate
- A disposition with an optional remark for the detail.
- Ifd
- One directory.
- Layout
- Byte order and offset width.
- Placed
- Parts that may overlap, resolved into non-overlapping siblings. Every byte goes to the candidate whose fate at that byte (the deepest part of its subtree there, or its body’s gap fate) ranks strongest; on a tie the candidate inserted first keeps it. Each candidate is then cut to the stretches it won.
- Placement
- A placed TIFF.
- Walk
- One parsed TIFF.
Enums§
- Count
- How long the extents of an
ExtentRuleare. - Kind
- Which directory an IFD is, by how the walk reached it.
- Loc
- Where an entry’s value lives.
Constants§
- BUDGET_
GAP - Detail for bytes a walk could not account for because a budget or cap stopped it.
- EXIF_
IFD - FREE_
BYTE_ COUNTS - FREE_
OFFSETS - GPS_IFD
- INTEROP_
IFD - JPEG_
AC_ TABLES - JPEG_
DC_ TABLES - JPEG_
IF_ LENGTH - JPEG_
IF_ OFFSET - JPEG_
Q_ TABLES - STRIP_
BYTE_ COUNTS - STRIP_
OFFSETS - SUB_
IFDS - TILE_
BYTE_ COUNTS - TILE_
OFFSETS
Traits§
- Rules
- What one decode path does with a TIFF’s directories, entries and extents.
Functions§
- add_
note - Push
textontonotes, keeping at mostMAX_NOTESand one marker. - chunk_
geometry - The decoded layout of
chunksstrips or tiles ofifdfrom its tags, as image-tiff computes it (readout_for_size,chunk_data_dimensions);Nonefor subsampled YCbCr or missing dimensions. - default_
chunk_ use Rules::chunk_use’s default, after image-tiff’sexpand_chunk: it reads whole chunk rows (right-edge padding included, then discarded) for the rows inside the image only. Uncompressed and PackBits chunks are split at that point; for other compression the end of the coded data is not found.- emit
- Push
c(and its children) underparent. - emit_
top - Push top-level
parts(non-overlapping, in file order) with gaps between them: beforelogical_enda gap isgap(a lone odd-offset byte between parts is a word-alignment pad); the caller’s trailing fill covers the rest. - get
- kind_
name - A short name for a kind of directory.
- place
- Turn a walk into non-overlapping parts.
firstare placed right after the header, ahead of the TIFF’s own parts. - push_
note - type_
name - type_
size - Size of one value of a TIFF field type,
Nonefor a type TIFF does not define. - union_
fate - The fate of a piece of a directory reached by several paths: the
strongest of
fate(kind, followed)over its roles, the first role on a tie. A decoder that reads the directory by any path reads the piece. - walk
- Parse the TIFF whose header is at
base, with every position belowlimit, following pointers the wayrulesdescribes. - walk_
ifd - Walk the directories starting at the absolute offset
at, which has no TIFF header of its own (a maker-note IFD): offsets inside are relative tobase, andlaygives the byte order. Every position stays belowlimit; the first directory is at pointer depthdepth.