TPDFlibModernImageFormat
Type reference, image handling
Description
TPDFlibModernImageFormat names the modern image formats the library handles besides the classic PDF image filters. DetermineModernImageFormat returns it after sniffing the first 4096 bytes of a stream, and DecodeModernImageToPNG and RegisterModernImageDecoderBackend consume it.
mifUnknown is the zero value and a valid answer: the bytes matched no supported signature. Passing it to the decoder fails immediately instead of guessing a format.
Syntax
Delphi
TPDFlibModernImageFormat = (mifUnknown, mifAVIF, mifHEIF, mifJPEGXL);Values
| mifUnknown | No supported modern format was recognised, or detection has not run |
|---|---|
| mifAVIF | AVIF brand in the ftyp box of an ISO base media file |
| mifHEIF | HEIF brand in the ftyp box of an ISO base media file |
| mifJPEGXL | JPEG XL codestream, or the JPEG XL container signature |
Remarks
Detection walks the leading ISO box structure and checks the ftyp brands rather than trusting a file extension; an AVIF brand wins over a HEIF brand when a file carries both.
ModernImageFormatName renders the same values as AVIF, HEIF, JPEG XL or Unknown, which is the form used in diagnostics.
The enum describes the detected format only. Whether decoding can succeed also depends on a registered backend or the codec library, which ModernImageCodecAvailable reports.
Detection repositions the stream to 0 and restores the saved position afterwards, so it expects a seekable stream and leaves the data ready for a later decode.
The decoder does not sniff the stream again: pass the value you detected to DecodeModernImageToPNG, and pass mifUnknown only when you intend the call to fail.
See also
DetermineModernImageFormat, ModernImageFormatName, DecodeModernImageToPNG, RegisterModernImageDecoderBackend