ImageReaderOptions Class
Immutable options for Image.OpenReader.
public sealed class ImageReaderOptionsConstructors
| Name | Description |
|---|---|
| ImageReaderOptions() |
ImageReaderOptions()
ImageReaderOptions.cspublic ImageReaderOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| CmykConversion | Gets the color conversion applied to images whose samples are CMYK inks (four-component JPEG), or null (the default) to reject them with an UnsupportedImageFeatureException. |
| Configuration | Gets the configuration of the reader. Its resource limits apply to the whole input, and images returned by the reader are charged to the reader's allocation scope until they are disposed. Defaults to ImageConfiguration.Default. |
| Conversion | Gets the options used to convert decoded samples to the reader's pixel type. Defaults to PixelConversionOptions.Default. |
| Default | Gets the default options. |
| FrameLimit | Gets the maximum number of displayed frames to read, or null to read all frames. Once the limit is reached, the reader reports a clean end of input without examining the remaining data. |
| LeaveOpen | Gets a value indicating whether a caller-provided stream is left open when the reader is disposed. Defaults to true. Streams opened by the path overloads are always owned and closed by the reader. |
| ScaleDenominator | Gets the factor by which the decoder divides the width and the height of the image, a power of two. Defaults to 1: the image is decoded at full resolution. |
| TargetSize | Gets the smallest size the decoder needs to produce, or null (the default) to decode at full resolution. A file that can be decoded at a reduced resolution is decoded at the largest ImageReaderOptions.ScaleDenominator it allows whose size is still at least this size in both dimensions; any other file is decoded at full resolution. |
CmykConversion
ImageReaderOptions.csGets the color conversion applied to images whose samples are CMYK inks (four-component JPEG), or null (the default) to reject them with an UnsupportedImageFeatureException.
public CmykConversionOptions? CmykConversion { get; init; }Property value
Remarks
No pixel format holds CMYK samples, so such an image can only be loaded by converting its colors. Like every color conversion it is explicit: set new CmykConversionOptions() to convert to sRGB. Other images are not affected.
Configuration
ImageReaderOptions.csGets the configuration of the reader. Its resource limits apply to the whole input, and images returned by the reader are charged to the reader's allocation scope until they are disposed. Defaults to ImageConfiguration.Default.
public ImageConfiguration Configuration { get; init; }Conversion
ImageReaderOptions.csGets the options used to convert decoded samples to the reader's pixel type. Defaults to PixelConversionOptions.Default.
public PixelConversionOptions Conversion { get; init; }Default
ImageReaderOptions.csFrameLimit
ImageReaderOptions.csGets the maximum number of displayed frames to read, or null to read all frames. Once the limit is reached, the reader reports a clean end of input without examining the remaining data.
public int? FrameLimit { get; init; }LeaveOpen
ImageReaderOptions.csScaleDenominator
ImageReaderOptions.csGets the factor by which the decoder divides the width and the height of the image, a power of two. Defaults to 1: the image is decoded at full resolution.
public int ScaleDenominator { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not a positive power of two.
ArgumentException- The value is not 1 and
ImageReaderOptions.TargetSizeis set.
Remarks
The decoded image has ceil(width / ScaleDenominator) by ceil(height / ScaleDenominator) pixels, computed from fewer samples than a full decode, for less time and memory, by the formats that support it (see the format reference of the readme). The pixels are close to a resize of the full image, not equal to it. The metadata is the one of the file, like after a resize.
A file that cannot be decoded at this scale (a format that only decodes at full resolution, or a scale that the file does not allow) is an UnsupportedImageFeatureException. Set ImageReaderOptions.TargetSize instead to get the smallest image the file allows without failing. The two properties cannot be set together.
TargetSize
ImageReaderOptions.csGets the smallest size the decoder needs to produce, or null (the default) to decode at full resolution. A file that can be decoded at a reduced resolution is decoded at the largest ImageReaderOptions.ScaleDenominator it allows whose size is still at least this size in both dimensions; any other file is decoded at full resolution.
public Size? TargetSize { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The width or the height of the value is zero.
ArgumentException- The value is not
nullandImageReaderOptions.ScaleDenominatoris not 1.
Remarks
The size is compared with the stored dimensions of the image, before its orientation is applied. The decoded image is usually larger than the target: resize it afterwards to get an exact size. For a thumbnail, this is much faster than resizing a full decode, with nearly the same result.