Class JxlWriterOptions
Options for writing JPEG XL.
public sealed class JxlWriterOptions : WriterOptions
- Inheritance
-
JxlWriterOptions
- Inherited Members
Examples
// Lossless JPEG XL, about the size cjxl -d 0 makes at the same effort (1 fastest to 7 smallest, 5 by default).
using Raster photo = Raster.Load("duck.png");
photo.Save("duck-lossless.jxl", new JxlWriterOptions { Lossless = true, Effort = 7 });
Properties
AlphaDistance
Gets the distance alpha is written at in lossy files, on Distance's scale: 0 (the default) keeps alpha exact, larger values (up to 25) code it lossy through Modular's squeeze, smaller but with softer edges. From a distance of 10 the whole image, alpha included, is coded at half size as cjxl codes it, so alpha is exact only below that. Lossless files keep alpha exact.
public float AlphaDistance { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 0 to 25.
Default
Gets the default options.
public static JxlWriterOptions Default { get; }
Property Value
Distance
Gets the Butteraugli-style distance lossy files are written at, as cjxl -d takes it: 1.0 is visually lossless, larger values give smaller files with more visible loss, 0.1 to 25. Defaults to null, which takes the distance from Quality.
public float? Distance { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 0.1 to 25.
Effort
Gets how hard the encoder works, 1 (fastest) to 10 (smallest files), on libjxl's effort scale for both kinds, so the same number gives about the same file as cjxl -e. Lossless: 1 is libjxl's fast lossless path, 2 and 3 use fixed trees, 4 and up learn the tree, 5 and up also try local palettes and color transforms, 8 and 9 learn from more properties and find LZ77 copies, and 10 tries every predictor under one tree for the whole image (and needs every pixel at once). Lossy: 1 to 3 use 8×8 DCTs and one quantization value, 4 adds finer LF and context modeling, 5 adaptive quantization, chroma from luma, Gaborish and simple block sizes, 6 the full block-size search, and 7 patches for repeated shapes such as text; 8 to 10 code lossy files as 7 does. Defaults to 5.
public int Effort { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 1 to 10.
ExtraChannels
Gets extra channels to write after the raster's own alpha (and black, for CMYK), such as depth, a selection mask, thermal data or a spot color: each coded lossless, in lossless and lossy files alike. Still images only; an animation refuses them. Defaults to null, none. Channels of a loaded file are not on its raster: read them with ReadExtraChannel(string, int, ReaderOptions?, EgamiContext?) and pass them here to keep them.
public IReadOnlyList<JxlExtraChannelImage>? ExtraChannels { get; init; }
Property Value
FirstFrameOnly
Gets whether only the first frame of a multi-frame raster is written, as a still image. Defaults to false: Save writes every frame as an animation, each with its Delay and the raster's LoopCount.
public bool FirstFrameOnly { get; init; }
Property Value
KeepTransparentColors
Gets whether lossy files keep the color of fully transparent pixels. false lets the encoder replace it by that of the visible neighbours, which makes files smaller (libjxl does that by default); true, the default as for WebP, keeps it as well as lossy coding does. Lossless files always keep it.
public bool KeepTransparentColors { get; init; }
Property Value
Lossless
Gets whether to write lossless (Modular, every sample exact) or lossy (VarDCT in XYB) data, or null (the default) to keep the kind of the JPEG XL file the raster was read from (lossless for a Modular file without XYB), and write lossy otherwise, as cjxl does for PNG input. Quality 100 with no Distance also writes lossless unless this is false.
public bool? Lossless { get; init; }
Property Value
- bool?
PhotonNoiseIso
Gets the ISO speed of film-like photon noise the decoder adds to lossy images, as cjxl --photon_noise_iso takes it (for example 3200 for a grainy look); the noise depends on the image size like a 35 mm sensor's. Defaults to null, no noise. Lossless files ignore it.
public float? PhotonNoiseIso { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not a positive number up to 10⁷.
Progressive
Gets whether lossy files are progressive as cjxl -p makes them: the LF image in a frame of its own (squeezed, so a 1:8 and smaller preview comes first) and the HF coefficients in three passes by frequency, so a partial file shows a coarse image that sharpens. Files grow slightly. Defaults to false. Lossless files ignore it.
public bool Progressive { get; init; }
Property Value
Quality
Gets the lossy quality, 0 (smallest) to 100 (best), on cjxl's -q scale, so the same number gives about the same file: 90 is distance 1.0 (visually lossless), each step below 100 adds 0.09 down to 30, and the distance grows faster below. 100 is lossless. Distance, when set, takes its place. Defaults to 90.
public int Quality { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is outside 0 to 100.