Struct TiffFile

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

Representation of a Tagged Image File.

This is the central structure of the crate. It holds all the other structures of the TIFF file and is responsible for writing them to a fs::File.

Implementations§

Source§

impl TiffFile

Source

pub fn new(ifds: IfdChain) -> TiffFile

Creates a new TiffFile from an IfdChain.

By default, a TiffFile is little-endian and has 42 as the magic number. If you want to change the endianness, consider chaining this function wih with_endianness.

§Examples

Creating the simplest valid TiffFile: a single Ifd with only one entry.

#[macro_use]
extern crate tiff_encoder;
use tiff_encoder::prelude::*;

let tiff_file = TiffFile::new(
    Ifd::new()
        .with_entry(0x0000, BYTE![0])
        .single()
);
Source

pub fn with_endianness(self, endian: Endianness) -> Self

Returns the same TiffFile, but with the specified Endianness.

§Examples

As this method returns Self, it can be chained when building a TiffFile.

#[macro_use]
extern crate tiff_encoder;
use tiff_encoder::prelude::*;
use tiff_encoder::write;

let tiff_file = TiffFile::new(
    Ifd::new()
        .with_entry(0x0000, BYTE![0])
        .single()
).with_endianness(write::Endianness::MM);
Source

pub fn write_to<P: AsRef<Path>>(self, file_path: P) -> Result<File>

Writes the TiffFile content to a new file created at the given path.

Doing so consumes the TiffFile. Returns the new fs::File wrapped in an io::Result.

§Examples

Note that, in this example, file is a fs::File, not a TiffFile.

#[macro_use]
extern crate tiff_encoder;
use tiff_encoder::prelude::*;

let file = TiffFile::new(
    Ifd::new()
        .with_entry(0x0000, BYTE![0])
        .single()
).write_to("file.tif").unwrap();
§Errors

This method returns the same errors as Write::write_all.

§Panics

This function will panic if the file trying to be written would exceed the maximum size of a TIFF file (2**32 bytes, or 4 GiB).

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