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) -> SelfSet 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) -> SelfSet the compression method to use
fn image_directory(&mut self) -> TiffResult<DirectoryEncoder<'_, W, K>>Create a
DirectoryEncoderto 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
DirectoryEncoderto 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
ImageEncoderto 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.