Struct TiffEncoder

pub struct TiffEncoder<W, K: TiffKind = TiffKindStandard> { /* private fields */ }

Encoder for Tiff and BigTiff files.

With this type you can get a DirectoryEncoder or a ImageEncoder to encode Tiff/BigTiff ifd directories with images.

See DirectoryEncoder and ImageEncoder.

Examples

# extern crate tiff;
# fn main() {
# let mut file = std::io::Cursor::new(Vec::new());
# let image_data = vec![0; 100*100*3];
use tiff::encoder::*;

// create a standard Tiff file
let mut tiff = TiffEncoder::new(&mut file).unwrap();
tiff.write_image::<colortype::RGB8>(100, 100, &image_data).unwrap();

// create a BigTiff file
let mut bigtiff = TiffEncoder::new_big(&mut file).unwrap();
bigtiff.write_image::<colortype::RGB8>(100, 100, &image_data).unwrap();

# }

Implementations

impl<W: Write + Seek> TiffEncoder<W>

fn new(writer: W) -> TiffResult<TiffEncoder<W, TiffKindStandard>>

Creates a new encoder for standard Tiff files.

To create BigTiff files, use [new_big][TiffEncoder::new_big] or [new_generic][TiffEncoder::new_generic].

impl<W: Write + Seek> TiffEncoder<W, TiffKindBig>

fn new_big(writer: W) -> TiffResult<Self>

Creates a new encoder for BigTiff files.

To create standard Tiff files, use [new][TiffEncoder::new] or [new_generic][TiffEncoder::new_generic].

impl<W: Write + Seek, K: TiffKind> TiffEncoder<W, K>

fn new_generic(writer: W) -> TiffResult<Self>

Creates a new Tiff or BigTiff encoder, inferred from the return type.

fn with_predictor(self, predictor: Predictor) -> Self

Set the predictor to use

A predictor is used to simplify the file before writing it. This is very useful when writing a file compressed using LZW as it can improve efficiency

fn with_compression(self, compression: Compression) -> Self

Set the compression method to use

fn image_directory(&mut self) -> TiffResult<DirectoryEncoder<'_, W, K>>

Create a DirectoryEncoder to encode an ifd (directory).

The caller is responsible for ensuring that the directory is a valid image in the main TIFF IFD sequence. To encode additional directories that are not linked into the sequence, use [Self::extra_directory][TiffEncoder::extra_directory].

fn extra_directory(&mut self) -> TiffResult<DirectoryEncoder<'_, W, K>>

Create a DirectoryEncoder to encode a non-image directory.

The directory is not linked into the sequence of directories. For instance, encode Exif directories or SubIfd directories with this method.

fn new_image<C: ColorType>(&mut self, width: u32, height: u32) -> TiffResult<ImageEncoder<'_, W, C, K>>

Create an ImageEncoder to encode an image one slice at a time.

fn write_image<C: ColorType>(&mut self, width: u32, height: u32, data: &[C::Inner]) -> TiffResult<()>
where
    [C::Inner]: TiffValue,

Convenience function to write an entire image from memory.

Auto Trait Implementations

impl<W, K> Freeze for TiffEncoder<W, K> where TiffWriter<W>: Freeze, PhantomData<K>: Freeze,

impl<W, K> RefUnwindSafe for TiffEncoder<W, K> where TiffWriter<W>: RefUnwindSafe, PhantomData<K>: RefUnwindSafe,

impl<W, K> Send for TiffEncoder<W, K> where TiffWriter<W>: Send, PhantomData<K>: Send,

impl<W, K> Sync for TiffEncoder<W, K> where TiffWriter<W>: Sync, PhantomData<K>: Sync,

impl<W, K> Unpin for TiffEncoder<W, K> where TiffWriter<W>: Unpin, PhantomData<K>: Unpin,

impl<W, K> UnsafeUnpin for TiffEncoder<W, K> where TiffWriter<W>: UnsafeUnpin, PhantomData<K>: UnsafeUnpin,

impl<W, K> UnwindSafe for TiffEncoder<W, K> where TiffWriter<W>: UnwindSafe, PhantomData<K>: UnwindSafe,

Blanket Implementations

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for TiffEncoder<W, K> where ST: ?Sized, DT: ?Sized,

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

impl<T> Any for TiffEncoder<W, K> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for TiffEncoder<W, K> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for TiffEncoder<W, K> where T: ?Sized,

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

impl<T> From<T> for TiffEncoder<W, K>

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T, U> Into<U> for TiffEncoder<W, K> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for TiffEncoder<W, K> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for TiffEncoder<W, K> where U: TryFrom<T>,

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