Skip to main content

TiffReader

Struct TiffReader 

Source
pub struct TiffReader<'a> { /* private fields */ }
Expand description

Reader for TIFF and BigTIFF files

Implementations§

Source§

impl<'a> TiffReader<'a>

Source

pub fn new(logger: &'a Logger) -> Self

Creates a new TIFF reader

Source

pub fn load(&mut self, filepath: &str) -> TiffResult<TIFF>

Loads a TIFF file from the given path

This is the main entry point for loading a TIFF file. It opens the file and delegates to the read() method.

§Arguments
  • filepath - Path to the TIFF file to load
§Returns

A TIFF structure containing the file’s contents

Source

pub fn read(&mut self, reader: &mut dyn SeekableReader) -> TiffResult<TIFF>

Reads a TIFF file from the given reader

This method handles the core process of reading a TIFF file:

  1. Detect byte order (little/big endian)
  2. Check for TIFF or BigTIFF format
  3. Read all IFDs (Image File Directories)
§Arguments
  • reader - Any struct implementing the SeekableReader trait
§Returns

A TIFF structure containing the file’s contents

Source

pub fn read_ifd( &self, reader: &mut dyn SeekableReader, offset: u64, number: usize, ) -> TiffResult<IFD>

Reads an IFD from the reader

An IFD (Image File Directory) contains all the metadata for a single image. It consists of a count followed by a series of entries, each describing an aspect of the image (dimensions, color space, compression, etc.)

§Arguments
  • reader - The seekable reader to use
  • offset - Offset in the file where the IFD starts
  • number - The index of this IFD in the file
§Returns

The parsed IFD structure

Source

pub fn read_tag_values( &self, reader: &mut dyn SeekableReader, ifd: &IFD, tag: u16, ) -> TiffResult<Vec<u64>>

Reads a tag’s value as a vector of u64

This is a utility method for extracting tag values from an IFD. It handles different field types and automatically converts them to u64.

§Arguments
  • reader - The seekable reader to use
  • ifd - The IFD containing the tag
  • tag - The tag number to read
§Returns

A vector of u64 values

Source

pub fn read_rational( &self, reader: &mut dyn SeekableReader, ) -> TiffResult<(u32, u32)>

Reads a rational value (numerator/denominator pair)

§Arguments
  • reader - The seekable reader to use
§Returns

A tuple with numerator and denominator

Source

pub fn read_u16(&self, reader: &mut dyn SeekableReader) -> TiffResult<u16>

Reads a u16 value using the current byte order handler

§Arguments
  • reader - The seekable reader to use
§Returns

The read u16 value

Source

pub fn read_u32(&self, reader: &mut dyn SeekableReader) -> TiffResult<u32>

Reads a u32 value using the current byte order handler

§Arguments
  • reader - The seekable reader to use
§Returns

The read u32 value

Source

pub fn read_u64(&self, reader: &mut dyn SeekableReader) -> TiffResult<u64>

Reads a u64 value using the current byte order handler

§Arguments
  • reader - The seekable reader to use
§Returns

The read u64 value

Source

pub fn read_f64(&self, reader: &mut dyn SeekableReader) -> TiffResult<f64>

Reads an f64 value using the current byte order handler

§Arguments
  • reader - The seekable reader to use
§Returns

The read f64 value

Source

pub fn read_ascii_string( &self, reader: &mut dyn SeekableReader, count: u64, ) -> TiffResult<String>

Reads an ASCII string

§Arguments
  • reader - The seekable reader to use
  • count - Number of bytes to read
§Returns

The string value, with trailing null characters removed

Source

pub fn read_ascii_string_at_offset( &self, offset: u64, count: u64, ) -> TiffResult<String>

Reads an ASCII string at a specific file offset

§Arguments
  • offset - File offset where the string starts
  • count - Number of bytes to read
§Returns

The string value

Source

pub fn get_file_path(&self) -> Option<&str>

Gets the file path if available

§Returns

The current file path or None

Source

pub fn is_big_tiff(&self) -> bool

Returns whether the current file is a BigTIFF

§Returns

true if the file is BigTIFF, false if it’s standard TIFF

Source

pub fn read_overviews(&mut self, filepath: &str) -> TiffResult<Vec<IFD>>

Read IFD overviews (reduced resolution subfiles)

Overviews are lower-resolution versions of the main image, used for faster display at reduced zoom levels.

§Arguments
  • filepath - Path to the TIFF file
§Returns

A vector of IFDs representing the overviews

Source

pub fn get_byte_order_handler(&self) -> Option<&Box<dyn ByteOrderHandler>>

Gets the current byte order handler

§Returns

A reference to the current byte order handler, or None if not yet set

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TiffReader<'a>

§

impl<'a> !UnwindSafe for TiffReader<'a>

§

impl<'a> Freeze for TiffReader<'a>

§

impl<'a> Send for TiffReader<'a>

§

impl<'a> Sync for TiffReader<'a>

§

impl<'a> Unpin for TiffReader<'a>

§

impl<'a> UnsafeUnpin for TiffReader<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.