Skip to main content

TiffFile

Struct TiffFile 

Source
pub struct TiffFile { /* private fields */ }
Expand description

A TIFF file handle.

Implementations§

Source§

impl TiffFile

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open a TIFF file from disk using safe file-backed I/O.

Source

pub fn open_with_options<P: AsRef<Path>>( path: P, options: OpenOptions, ) -> Result<Self>

Open a TIFF file from disk using safe file-backed I/O with explicit decoder options.

Source

pub unsafe fn open_mmap<P: AsRef<Path>>(path: P) -> Result<Self>

Open a TIFF file from disk using memory-mapped I/O.

§Safety

The caller must guarantee that the mapped file is not mutated or truncated while the returned TiffFile is alive. This includes writes through other file handles and writes from other processes.

Source

pub unsafe fn open_mmap_with_options<P: AsRef<Path>>( path: P, options: OpenOptions, ) -> Result<Self>

Open a TIFF file from disk using memory-mapped I/O with explicit decoder options.

§Safety

The caller must guarantee that the mapped file is not mutated or truncated while the returned TiffFile is alive. This includes writes through other file handles and writes from other processes.

Source

pub fn from_bytes(data: Vec<u8>) -> Result<Self>

Open a TIFF file from an owned byte buffer (WASM-compatible).

Source

pub fn from_bytes_with_options( data: Vec<u8>, options: OpenOptions, ) -> Result<Self>

Open a TIFF file from bytes with explicit decoder options.

Source

pub fn from_source(source: SharedSource) -> Result<Self>

Open a TIFF file from an arbitrary random-access source.

Source

pub fn from_source_with_options( source: SharedSource, options: OpenOptions, ) -> Result<Self>

Open a TIFF file from an arbitrary random-access source with options.

Source

pub fn byte_order(&self) -> ByteOrder

Returns the byte order of the TIFF file.

Source

pub fn is_bigtiff(&self) -> bool

Returns true if this is a BigTIFF file.

Source

pub fn ifd_count(&self) -> usize

Returns the number of IFDs (images/pages) in the file.

Source

pub fn ifd(&self, index: usize) -> Result<&Ifd>

Returns the IFD at the given index.

Source

pub fn ifds(&self) -> &[Ifd]

Returns all parsed IFDs.

Source

pub fn raw_bytes(&self) -> Option<&[u8]>

Returns the raw file bytes when the source exposes a resident immutable slice.

This returns Some for in-memory and memory-mapped sources. It returns None for the default safe file-backed source.

Source

pub fn source(&self) -> &dyn TiffSource

Returns the backing source.

Source

pub fn read_ifd_at_offset(&self, offset: u64) -> Result<Ifd>

Parse an IFD at an arbitrary file offset.

Source

pub fn read_image_bytes(&self, ifd_index: usize) -> Result<Vec<u8>>

Decode an image into native-endian interleaved storage sample bytes.

Source

pub fn read_image_bytes_from_ifd(&self, ifd: &Ifd) -> Result<Vec<u8>>

Decode an arbitrary IFD into native-endian interleaved storage sample bytes.

Source

pub fn read_decoded_image_bytes(&self, ifd_index: usize) -> Result<Vec<u8>>

Decode an image into native-endian interleaved color-decoded pixel bytes.

Source

pub fn read_decoded_image_bytes_from_ifd(&self, ifd: &Ifd) -> Result<Vec<u8>>

Decode an arbitrary IFD into native-endian interleaved color-decoded pixel bytes.

Source

pub fn read_image_sample_bytes(&self, ifd_index: usize) -> Result<Vec<u8>>

Decode an image into native-endian interleaved storage sample bytes.

This is an explicit alias for Self::read_image_bytes.

Source

pub fn read_image_sample_bytes_from_ifd(&self, ifd: &Ifd) -> Result<Vec<u8>>

Decode an arbitrary IFD into native-endian interleaved storage sample bytes.

This is an explicit alias for Self::read_image_bytes_from_ifd.

Source

pub fn read_window_bytes( &self, ifd_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window into native-endian interleaved storage sample bytes.

Source

pub fn read_decoded_window_bytes( &self, ifd_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window into native-endian interleaved color-decoded pixel bytes.

Source

pub fn read_window_sample_bytes( &self, ifd_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window into native-endian interleaved storage sample bytes.

This is an explicit alias for Self::read_window_bytes.

Source

pub fn read_window_bytes_from_ifd( &self, ifd: &Ifd, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window from an arbitrary IFD into native-endian interleaved storage sample bytes.

Source

pub fn read_decoded_window_bytes_from_ifd( &self, ifd: &Ifd, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window from an arbitrary IFD into native-endian interleaved color-decoded pixel bytes.

Source

pub fn read_window_sample_bytes_from_ifd( &self, ifd: &Ifd, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window from an arbitrary IFD into native-endian interleaved storage sample bytes.

This is an explicit alias for Self::read_window_bytes_from_ifd.

Source

pub fn read_band_bytes( &self, ifd_index: usize, band_index: usize, ) -> Result<Vec<u8>>

Decode a single storage-domain band into native-endian sample bytes.

Source

pub fn read_band_bytes_from_ifd( &self, ifd: &Ifd, band_index: usize, ) -> Result<Vec<u8>>

Decode a single storage-domain band from an arbitrary IFD into native-endian sample bytes.

Source

pub fn read_band_window_bytes( &self, ifd_index: usize, band_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window from one storage-domain band into native-endian sample bytes.

Source

pub fn read_band_window_bytes_from_ifd( &self, ifd: &Ifd, band_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<Vec<u8>>

Decode a pixel window from one storage-domain band in an arbitrary IFD into native-endian sample bytes.

Source

pub fn read_window<T: TiffSample>( &self, ifd_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window into a typed ndarray of storage-domain samples.

Single-band rasters are returned as shape [rows, cols]. Multi-band rasters are returned as shape [rows, cols, samples_per_pixel].

Source

pub fn read_window_from_ifd<T: TiffSample>( &self, ifd: &Ifd, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window from an arbitrary IFD into a typed ndarray of storage-domain samples.

Source

pub fn read_decoded_window<T: TiffSample>( &self, ifd_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window into a typed ndarray of color-decoded pixels.

Single-channel decoded rasters are returned as shape [rows, cols]. Multi-channel decoded rasters are returned as shape [rows, cols, channels].

Source

pub fn read_decoded_window_from_ifd<T: TiffSample>( &self, ifd: &Ifd, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window from an arbitrary IFD into a typed ndarray of color-decoded pixels.

Source

pub fn read_window_samples<T: TiffSample>( &self, ifd_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window into a typed ndarray of storage-domain samples.

Single-band rasters are returned as shape [rows, cols]. Multi-band rasters are returned as shape [rows, cols, samples_per_pixel].

Source

pub fn read_window_samples_from_ifd<T: TiffSample>( &self, ifd: &Ifd, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window from an arbitrary IFD into a typed ndarray of storage-domain samples.

Source

pub fn read_band<T: TiffSample>( &self, ifd_index: usize, band_index: usize, ) -> Result<ArrayD<T>>

Decode one storage-domain band into a typed [height, width] ndarray.

Source

pub fn read_band_from_ifd<T: TiffSample>( &self, ifd: &Ifd, band_index: usize, ) -> Result<ArrayD<T>>

Decode one storage-domain band from an arbitrary IFD into a typed [height, width] ndarray.

Source

pub fn read_band_window<T: TiffSample>( &self, ifd_index: usize, band_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window from one storage-domain band into a typed [rows, cols] ndarray.

Source

pub fn read_band_window_from_ifd<T: TiffSample>( &self, ifd: &Ifd, band_index: usize, row_off: usize, col_off: usize, rows: usize, cols: usize, ) -> Result<ArrayD<T>>

Decode a window from one storage-domain band in an arbitrary IFD into a typed [rows, cols] ndarray.

Source

pub fn read_image<T: TiffSample>(&self, ifd_index: usize) -> Result<ArrayD<T>>

Decode an image into a typed ndarray of storage-domain samples.

Single-band rasters are returned as shape [height, width]. Multi-band rasters are returned as shape [height, width, samples_per_pixel].

Source

pub fn read_image_from_ifd<T: TiffSample>(&self, ifd: &Ifd) -> Result<ArrayD<T>>

Decode an arbitrary IFD into a typed ndarray of storage-domain samples.

Source

pub fn read_decoded_image<T: TiffSample>( &self, ifd_index: usize, ) -> Result<ArrayD<T>>

Decode an image into a typed ndarray of color-decoded pixels.

Single-channel decoded rasters are returned as shape [height, width]. Multi-channel decoded rasters are returned as shape [height, width, channels].

Source

pub fn read_decoded_image_from_ifd<T: TiffSample>( &self, ifd: &Ifd, ) -> Result<ArrayD<T>>

Decode an arbitrary IFD into a typed ndarray of color-decoded pixels.

Source

pub fn read_image_samples<T: TiffSample>( &self, ifd_index: usize, ) -> Result<ArrayD<T>>

Decode an image into a typed ndarray of storage-domain samples.

This is an explicit alias for Self::read_image.

Source

pub fn read_image_samples_from_ifd<T: TiffSample>( &self, ifd: &Ifd, ) -> Result<ArrayD<T>>

Decode an arbitrary IFD into a typed ndarray of storage-domain samples.

This is an explicit alias for Self::read_image_from_ifd.

Auto Trait Implementations§

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> 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, 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.