Class ImageBuffer.ImageEncoderOptions
The settings consumed by Encode(ImageOutputFormat, ImageEncoderOptions), Save(string, ImageEncoderOptions) and their siblings: the knobs of every encoder, the metadata families written back, and the colour space the samples are written in. A setting the chosen format has no use for is ignored, never an error; asking a format for a colour space it cannot hold (CMYK in PNG or WebP) throws. Values clamp silently to their valid range on assignment, so a UI control or a wire request can bind directly; the defaults describe a faithful re-encode.
public sealed class ImageBuffer.ImageEncoderOptions
- Inheritance
-
ImageBuffer.ImageEncoderOptions
- Inherited Members
Examples
using LMKit.Media.Image;
using ImageBuffer image = ImageBuffer.Load("scan.tif");
// A web copy: sRGB, progressive JPEG at quality 82, camera data kept, profile dropped.
byte[] web = image.Encode(ImageOutputFormat.Jpeg, new ImageBuffer.ImageEncoderOptions
{
Quality = 82,
Progressive = true,
ColorTarget = ImageColorTarget.Rgb,
});
// A press copy: four inks through the printer's profile, in a Deflate TIFF.
byte[] press = image.Encode(ImageOutputFormat.Tiff, new ImageBuffer.ImageEncoderOptions
{
TiffCompression = TiffCompression.Deflate,
ColorTarget = ImageColorTarget.Cmyk,
TargetProfile = IccProfile.FromFile("press.icc"),
});
Remarks
- PNG reads CompressionLevel, Interlace, Metadata, ColorTarget (RGB / Gray).
- JPEG reads Quality, Progressive, ChromaSubsampling, OptimizeCoding, Metadata, ColorTarget (all four).
- WebP reads Quality, Lossless, Effort, Metadata, ColorTarget (RGB / Gray).
- TIFF reads TiffCompression, Quality (JPEG-in-TIFF), Metadata, ColorTarget (all four).
- BMP and TGA read RunLengthEncoding; PNM reads nothing.
Properties
- BlackPointCompensation
Black point compensation: the source's darkest black maps to the target's darkest black instead of being clipped, so shadows keep their detail on paper. Default on.
- ChromaSubsampling
How much colour detail a JPEG keeps. Default Auto.
- ColorTarget
The colour space the samples are written in. Default Original.
- CompressionLevel
The PNG deflate level, 0 (stored, fastest) to 9 (smallest, slowest); default 6.
- Effort
How hard the WebP encoder works for a smaller file, 0 (fastest) to 6 (smallest); default 4, libwebp's own default.
- Interlace
Interlaced PNG (Adam7): the picture sharpens progressively while loading. Default off.
- Metadata
The metadata families written back into the file, as far as the format can hold them. Default All: a re-encode keeps the colour profile, the EXIF block, the XMP packet and the IPTC record it read. None writes a clean file.
- OptimizeCoding
Optimal Huffman tables for a JPEG: a few percent smaller, a little slower to write. Default off.
- Progressive
Progressive JPEG: the picture sharpens in passes while loading; a little smaller too. Default off.
- Quality
The lossy quality, 0 to 100 (default 90): JPEG, lossy WebP and JPEG-in-TIFF. Around 80-85 is visually transparent for most photographs; 90 and above keeps full chroma under Auto.
- RenderingIntent
The rendering intent of the colour conversion. Default Perceptual.
- RunLengthEncoding
Run-length coding for BMP (8-bit gray only) and TGA. Default off.
- TargetProfile
The profile of the target space: an RGB profile for Rgb (written into the file), a gray profile for Gray, a press profile for Cmyk.
null(the default) means sRGB, the SDK's gray profile and GenericCmyk respectively. A profile of the wrong kind for the target throws at encode time.
- TiffCompression
The TIFF codec. Default Auto.