OptimizeImages

Images, optimization

Description

Re-encodes eligible image XObjects as JPEG and keeps a replacement only when it is smaller than the original

Syntax

Delphi

Function TPDFlib.OptimizeImages(Quality: Integer): Integer;

Parameters

QualityJPEG quality from 1 through 100, or 0 for the configured default quality

Return values

The number of image XObjects replaced

Remarks

Images already encoded with DCT, JPX or JBIG2 and images used as stencil or color-key masks are preserved

Eligible images are at least 32 pixels in each dimension and use a stream of at least 256 bytes

Independent images run in bounded worker batches configured by SetOptimizationWorkers; dictionaries with indirect dependencies stay on the serial path

Document mutations follow object order and an encoded result that is not smaller is discarded

The operation reports progress and Abort stops between discovery and batch boundaries

See also

GetImageInfoJSON, CompressImages