Ifd

Struct Ifd 

Source
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: u64

Offset to the next IFD (0 if this is the last IFD)

Implementations§

Source§

impl Ifd

Source

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 bytes
  • header - The TIFF header
§Errors

Returns an error if the bytes are too short for the declared entry count.

Source

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 IFD
  • header - The TIFF header
Source

pub fn get_entry(&self, tag_id: u16) -> Option<&IfdEntry>

Get an entry by its tag ID.

Source

pub fn get_entry_by_tag(&self, tag: TiffTag) -> Option<&IfdEntry>

Get an entry by its known TiffTag.

Source

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.

Source

pub fn get_u64(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u64>

Get an inline u64 value for a tag.

Source

pub fn get_u16(&self, tag: TiffTag, byte_order: ByteOrder) -> Option<u16>

Get an inline u16 value for a tag.

Source

pub fn is_tiled(&self) -> bool

Check if this IFD has tile organization (vs strip).

Returns true if TileWidth and TileLength tags are present.

Source

pub fn is_stripped(&self) -> bool

Check if this IFD has strip organization.

Returns true if StripOffsets tag is present.

Source

pub fn image_width(&self, byte_order: ByteOrder) -> Option<u32>

Get image width from this IFD.

Source

pub fn image_height(&self, byte_order: ByteOrder) -> Option<u32>

Get image height (length) from this IFD.

Source

pub fn tile_width(&self, byte_order: ByteOrder) -> Option<u32>

Get tile width from this IFD.

Source

pub fn tile_height(&self, byte_order: ByteOrder) -> Option<u32>

Get tile height (length) from this IFD.

Source

pub fn compression(&self, byte_order: ByteOrder) -> Option<u16>

Get compression scheme from this IFD.

Source

pub fn entry_count(&self) -> usize

Get the number of entries in this IFD.

Trait Implementations§

Source§

impl Clone for Ifd

Source§

fn clone(&self) -> Ifd

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ifd

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more