API referenceForms

pdfReadImageFormat

Read an image file's geometry (dimensions, effective

C
BOOL32 __stdcall pdfReadImageFormatA(PPDF IPDF, const char* FileName, uint32_t* Width, uint32_t* Height, int32_t* BitsPerPixel, int32_t* UseZip);
BOOL32 __stdcall pdfReadImageFormatW(PPDF IPDF, const wchar_t* FileName, uint32_t* Width, uint32_t* Height, int32_t* BitsPerPixel, int32_t* UseZip);
Delphi
function pdfReadImageFormatA(const IPDF: PPDF; const FileName: PAnsiChar; var Width, Height: Cardinal; var BitsPerPixel, UseZip: Integer): LongBool; stdcall;
function pdfReadImageFormatW(const IPDF: PPDF; const FileName: PWideChar; var Width, Height: Cardinal; var BitsPerPixel, UseZip: Integer): LongBool; stdcall;

Purpose. Read an image file's geometry (dimensions, effective bits-per-pixel, and whether it will be Flate- vs. DCT-compressed if embedded) without loading it into the document — a pure inspection call using the SDK's own general-purpose image loader.

Description. Delegates to the same LoadImageFile used by the real image-embedding path (V07), decodes the file fully into a transient TLumasLoadedImage, reports Width/Height and BitsPerPixel = Img.BPC * Img.NumComps (bit depth × component count — e.g. 8-bit RGB = 24, not the file's own nominal bit depth if that differs), frees the loaded image, and returns. UseZip is derived, not read from the file: 1 unless the image is a JPEG (Ord(Img.Kind <> ikJpeg)) — i.e. it reports "would this be Flate/Zip-compressed if embedded via this SDK's default policy" rather than any property of the file itself. Any format LoadImageFile supports (JPEG/PNG/BMP/GIF/TIFF/JP2, per V07) works here.

Parameters.

ParameterDescription
IPDFDocument handle (used only to resolve the doc context; the file itself is read independently of document state).
FileNamePath to the image file.
Width, HeightOutput: pixel dimensions.
BitsPerPixelOutput: BPC * NumComps, not necessarily the file's own reported bit depth.
UseZipOutput: 1 unless the image is JPEG — reflects this SDK's embedding compression policy, not a file property.

Return value. True if the file loaded and decoded successfully; False otherwise (file missing, unsupported/corrupt format).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Forms
Category

Core

Exported names

pdfReadImageFormat pdfReadImageFormatA pdfReadImageFormatW

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.