DownsampleImagesEx

Images, Optimisation

Description

Per-class downsampling strategy for bitonal, grayscale and colour images

Syntax

Delphi

Function DownsampleImagesEx(ColorMaxDPI, GrayMaxDPI, BitonalMaxDPI, ColorQuality, GrayQuality, Flags: Integer): Integer;

Return values

0No document, a budget below the 24 DPI floor, or no image needed resampling
NNumber of images resampled and re-encoded

Remarks

Every image XObject is classified from /ColorSpace and /BitsPerComponent: 1-bit images are bitonal, DeviceGray, CalGray and single-channel ICCBased streams are grayscale, everything else is colour. Each class gets its own DPI budget and JPEG quality, so a typical mixed scan can keep line art at 300 DPI lossless while photographs drop to 150 DPI quality 75. Bitonal images always take the lossless PNG path because JPEG artefacts are unacceptable on 1-bit content. Flags bit 1 keeps the original stream when the re-encoded bytes are not smaller. Downsampling uses the same box filter and DPI estimation from page width as DownsampleImages.

Example

PDF.DownsampleImagesEx(150, 200, 300, 75, 85, 1);

See also

DownsampleImages, GetImageListItemNativeFormat