Struct tiff_encoder::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
impl TiffFile
sourcepub fn new(ifds: IfdChain) -> TiffFile
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.
use tiff_encoder::*;
use tiff_encoder::tiff_type::*;
let tiff_file = TiffFile::new(
Ifd::new()
.with_entry(0x0000, BYTE::single(0))
.single()
);sourcepub fn with_endianness(self, endian: Endianness) -> Self
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.
use tiff_encoder::*;
use tiff_encoder::tiff_type::*;
let tiff_file = TiffFile::new(
Ifd::new()
.with_entry(0x0000, BYTE::single(0))
.single()
).with_endianness(Endianness::MM);sourcepub fn write_to(self, file_path: &str) -> Result<File>
pub fn write_to(self, file_path: &str) -> 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.
use tiff_encoder::*;
use tiff_encoder::tiff_type::*;
let file = TiffFile::new(
Ifd::new()
.with_entry(0x0000, BYTE::single(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).