Class TiffWriterOptions
Options for writing TIFF.
public sealed class TiffWriterOptions : WriterOptions
- Inheritance
-
TiffWriterOptions
- Inherited Members
Examples
// Each pixel type is written at its own depth: 16-bit color stays 16-bit. Deflate with the predictor is the default.
photo.Save("duck.tif");
// Tiles, LZW, BigTIFF, or the smallest exact form the pixels allow.
photo.Save("tiled.tif", new TiffWriterOptions { Compression = TiffCompression.Lzw, TileSize = 256, Layout = TiffLayout.Auto });
photo.Save("small.tif", new TiffWriterOptions { Reduce = true });
// JPEG inside TIFF: RGB is written as YCbCr 4:2:0 with the tables shared by every strip.
photo.Save("photo.tif", new TiffWriterOptions { Compression = TiffCompression.Jpeg, Quality = 90 });
Remarks
Re-saving a raster loaded from TIFF keeps the source's compression, predictor, tiling and byte order for every option left at null, so a round trip writes the same kind of file. A JPEG or WebP source compression is kept only while the raster is unchanged since loading; otherwise it falls back to Deflate, to avoid a second lossy pass.
Properties
AssociatedAlpha
Gets whether straight alpha is written premultiplied, with ExtraSamples 1 (associated). Premultiplied pixel types are always written that way. Defaults to false.
public bool AssociatedAlpha { get; init; }
Property Value
Compression
Gets the compression, or null (the default) for the TIFF source's, else Deflate. The writer takes None, Lzw, Deflate, Zstd, Lzma, PackBits, CcittGroup3 and CcittGroup4 (1-bit images only), Jpeg and Webp.
public TiffCompression? Compression { get; init; }
Property Value
CompressionLevel
Gets the Deflate level, 0 (fastest) to 9 (smallest). Defaults to 5, as PNG's.
public int CompressionLevel { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 0 to 9.
Default
Gets the default options.
public static TiffWriterOptions Default { get; }
Property Value
Layout
Gets whether classic TIFF or BigTIFF is written. Defaults to Classic, which throws before writing anything when the uncompressed pixels pass 4 GB.
public TiffLayout Layout { get; init; }
Property Value
LzmaPreset
Gets the LZMA preset, 0 (fastest) to 9 (smallest), for Lzma, with xz's meanings. Defaults to 6, as libtiff's LZMA_PRESET does. LZMA writes slowly at the higher presets; CompressionLevel is Deflate's alone.
public int LzmaPreset { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 0 to 9.
ParallelCompression
Gets whether strips and tiles are compressed on up to MaxParallelism threads. The file is the same either way. Defaults to false.
public bool ParallelCompression { get; init; }
Property Value
Predictor
Gets the predictor for LZW, Deflate, Zstandard and LZMA, or null (the default) for the source's, else Horizontal for 8, 16 and 32-bit integer samples and FloatingPoint for float samples. None turns it off.
public TiffPredictor? Predictor { get; init; }
Property Value
Quality
Gets the quality of JPEG and lossy WebP compression, 1 to 100, with the JPEG and WebP writers' meanings. Defaults to 75.
public int Quality { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 1 to 100.
Reduce
Gets whether to write the smallest exact form the pixels allow: 1 bit when every pixel is black or white, gray when red, green and blue are equal, a palette of up to 256 colors for opaque images, 8 bits when every 16-bit sample is a multiple of 257. Defaults to false: each pixel type is written at its own depth.
public bool Reduce { get; init; }
Property Value
TileSize
Gets the side of square tiles, a multiple of 16, or 0 for strips of about 64 KB of uncompressed rows, or null (the default) for the source's layout, else strips.
public int? TileSize { get; init; }
Property Value
- int?
Exceptions
- ArgumentOutOfRangeException
The value is negative or not a multiple of 16.
ZstdLevel
Gets the Zstandard level, 1 (fastest) to 22 (smallest), for Zstd. Defaults to 9, as libtiff's ZSTD_LEVEL does. CompressionLevel is Deflate's alone.
public int ZstdLevel { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 1 to 22.