PeachImage

PeachImage.DecoderOptions

DecoderOptions.ScaleDenominator Property

Decodes at a reduced size: 1 (the default, full size), 2, 4 or 8 for 1/2, 1/4 or 1/8 of the width and height, rounded up (ceil(size / N)). Three formats reduce natively and save most of the decode work and memory: JPEG scales in the DCT domain (so a 24 megapixel photo at 1/8 never builds a full-size image), JPEG 2000 drops resolution levels (its wavelet low-pass differs from a box average, so expect larger differences from a resize), and JPEG XL decodes 1/8 from the DC image of a plain VarDCT still (1/2 and 1/4, and modular, lossless, alpha, animated and other feature-heavy files, decode at full size). Every other format decodes at full size and is then averaged down, so the result size is the same but nothing is saved. TargetSize, when set, chooses the denominator instead.

public int ScaleDenominator { get; init; }

Property Value

System.Int32

Exceptions

System.ArgumentOutOfRangeException
The value is not 1, 2, 4 or 8 (reported when the image is loaded).

Remarks

MaxPixels and MaxExpansionRatio are checked against the size the header declares, not the reduced size. ImageInfo from Identify(Stream, DecoderOptions) also reports the declared size. A progressive JPEG reduces the same way as a baseline one, and the progressive previews (PreviewAvailable) arrive at the reduced size. The reduced image is a faithful lower-resolution rendition, but not bit-identical to resizing the full decode (DCT-domain reduction is close to a box filter), so expect small differences. The metadata and EXIF orientation are those of the file; see ApplyOrientation.