Enum JpegColorSpace
The color model a JPEG's components are stored in.
public enum JpegColorSpace
Fields
Cmyk = 3Four components of cyan, magenta, yellow and black (Adobe transform 0). Converted to RGB when decoded.
Gray = 0One component of luma.
Rgb = 2Three components of red, green and blue, as an Adobe segment with transform 0 says.
YCbCr = 1Three components of luma and chroma: the usual JFIF case.
Ycck = 4Four components, YCbCr plus black (Adobe transform 2). Converted to RGB when decoded.
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 });