Class JpegReaderOptions
Options for reading JPEG, on top of the general ReaderOptions.
public sealed record JpegReaderOptions : ReaderOptions, IEquatable<ReaderOptions>, IEquatable<JpegReaderOptions>
- Inheritance
-
JpegReaderOptions
- Implements
- Inherited Members
Examples
using Raster photo = Raster.Load("duck.jpg", options: new JpegReaderOptions { FastUpsampling = true });
JpegDetails details = (JpegDetails)photo.Metadata.FormatDetails!;
Console.WriteLine($"{details.ColorSpace}, progressive: {details.Progressive}, quality about {details.EstimatedQuality}");
foreach (JpegComponent component in details.Components)
{
Console.WriteLine($"Component {component.Id}: sampled {component.HorizontalSampling} × {component.VerticalSampling}");
}
// Gray output, and 4:4:4 (no chroma subsampling) for sharp colored edges.
photo.Save("gray.jpg", new JpegWriterOptions { ColorType = JpegColorType.Gray });
photo.Save("sharp.jpg", new JpegWriterOptions { Quality = 90, Subsampling = ChromaSubsampling.Subsample444 });
Properties
Default
Gets the default options.
public static JpegReaderOptions Default { get; }
Property Value
FastUpsampling
Gets a value indicating whether subsampled chroma is replicated instead of smoothly interpolated. Off by default, which matches libjpeg-turbo, Skia and browsers; on is a little faster and gives blockier color edges, the way some other decoders look.
public bool FastUpsampling { get; init; }