function SelectPdfImageCodec(const Candidate: TPdfImageCodecCandidate;
AllowedCodecs: TPdfImageCodecs; MinimumSavingBytes: Int64 = 1): TPdfImageCodecDecision;
| Candidate | TPdfImageCodecCandidate |
| AllowedCodecs | TPdfImageCodecs |
| MinimumSavingBytes | Int64 |
TPdfImageCodecDecisionSelectPdfImageCodec is a pure decision helper that compares the EncodedBytes estimates recorded on the candidate and returns which codec should store the image
Each allowed codec is first checked for eligibility: picJpeg requires no alpha, a non-bilevel image, 8 bits per component, 1, 3, or 4 components, and an unknown or greater-than-256 unique color count; picJpx requires a non-bilevel image with at least 8 bits per component and 1 to 4 components; picCcittGroup4 requires a bilevel image without alpha, 1 bit per component, and a single component; picFlate accepts at least 1 bit per component and at least 1 component
Among the eligible codecs the smallest positive EncodedBytes value wins, and the decision reports OriginalBytes, SelectedBytes, and SavedBytes
ReplaceOriginal is True only when the winner is not picKeepOriginal and SavedBytes reaches MinimumSavingBytes; otherwise the decision is reset to picKeepOriginal with zero saved bytes
Decision := SelectPdfImageCodec(Candidate, [picJpeg, picJpx, picFlate], 1024);
if Decision.ReplaceOriginal then
ReEncode := Decision.Codec;