pub struct Ifd {
pub entries: Vec<IfdEntry>,
pub next_ifd_offset: u64,
/* private fields */
}Expand description
A parsed Image File Directory (IFD).
An IFD contains metadata about one image in the TIFF file. WSI files typically have multiple IFDs: one for each pyramid level, plus label/macro images.
The entries are stored both as a vector (preserving order) and as a hashmap (for fast lookup by tag).
Fields§
§entries: Vec<IfdEntry>All entries in this IFD, in file order
next_ifd_offset: u64Offset to the next IFD (0 if this is the last IFD)
Implementations§
Source§impl Ifd
impl Ifd
Sourcepub fn parse(bytes: &[u8], header: &TiffHeader) -> Result<Self, TiffError>
pub fn parse(bytes: &[u8], header: &TiffHeader) -> Result<Self, TiffError>
Parse an IFD from raw bytes.
The bytes should start at the IFD offset and contain:
- Entry count (2 or 8 bytes depending on format)
- All entries (12 or 20 bytes each)
- Next IFD offset (4 or 8 bytes)
§Arguments
bytes- Raw IFD bytesheader- The TIFF header
§Errors
Returns an error if the bytes are too short for the declared entry count.
Sourcepub fn calculate_size(entry_count: u64, header: &TiffHeader) -> usize
pub fn calculate_size(entry_count: u64, header: &TiffHeader) -> usize
Calculate the total size in bytes needed to read this IFD.
This can be used to determine how many bytes to fetch before parsing. Note: This is the size of the IFD structure itself, not including any values stored at external offsets.
§Arguments
entry_count- Number of entries in the IFDheader- The TIFF header
Sourcepub fn get_entry_by_tag(&self, tag: TiffTag) -> Option<&IfdEntry>
pub fn get_entry_by_tag(&self, tag: TiffTag) -> Option<&IfdEntry>
Get an entry by its known TiffTag.
Sourcepub fn get_u32(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u32>
pub fn get_u32(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u32>
Get an inline u32 value for a tag.
This is a convenience method for reading simple scalar values like ImageWidth, ImageLength, TileWidth, etc.
Sourcepub fn get_u64(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u64>
pub fn get_u64(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u64>
Get an inline u64 value for a tag.
Sourcepub fn get_u16(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u16>
pub fn get_u16(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u16>
Get an inline u16 value for a tag.
Sourcepub fn is_tiled(&self) -> bool
pub fn is_tiled(&self) -> bool
Check if this IFD has tile organization (vs strip).
Returns true if TileWidth and TileLength tags are present.
Sourcepub fn is_stripped(&self) -> bool
pub fn is_stripped(&self) -> bool
Check if this IFD has strip organization.
Returns true if StripOffsets tag is present.
Sourcepub fn image_width(&self, byte_order: ByteOrder) -> Option<u32>
pub fn image_width(&self, byte_order: ByteOrder) -> Option<u32>
Get image width from this IFD.
Sourcepub fn image_height(&self, byte_order: ByteOrder) -> Option<u32>
pub fn image_height(&self, byte_order: ByteOrder) -> Option<u32>
Get image height (length) from this IFD.
Sourcepub fn tile_width(&self, byte_order: ByteOrder) -> Option<u32>
pub fn tile_width(&self, byte_order: ByteOrder) -> Option<u32>
Get tile width from this IFD.
Sourcepub fn tile_height(&self, byte_order: ByteOrder) -> Option<u32>
pub fn tile_height(&self, byte_order: ByteOrder) -> Option<u32>
Get tile height (length) from this IFD.
Sourcepub fn compression(&self, byte_order: ByteOrder) -> Option<u16>
pub fn compression(&self, byte_order: ByteOrder) -> Option<u16>
Get compression scheme from this IFD.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Get the number of entries in this IFD.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ifd
impl RefUnwindSafe for Ifd
impl Send for Ifd
impl Sync for Ifd
impl Unpin for Ifd
impl UnwindSafe for Ifd
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more