API referenceImages

pdfReadImageResolutionEx

Read the embedded DPI (dots-per-inch) resolution metadata of

C
BOOL32 __stdcall pdfReadImageResolutionA(PPDF IPDF, const char* FileName, uint32_t Index, uint32_t* ResX, uint32_t* ResY);
BOOL32 __stdcall pdfReadImageResolutionW(PPDF IPDF, const wchar_t* FileName, uint32_t Index, uint32_t* ResX, uint32_t* ResY);
BOOL32 __stdcall pdfReadImageResolutionEx(PPDF IPDF, void* Buffer, uint32_t BufSize, uint32_t Index, uint32_t* ResX, uint32_t* ResY);
Delphi
function pdfReadImageResolutionA(const IPDF: PPDF; const FileName: PAnsiChar; Index: Cardinal; var ResX, ResY: Cardinal): LongBool; stdcall;
function pdfReadImageResolutionW(const IPDF: PPDF; const FileName: PWideChar; Index: Cardinal; var ResX, ResY: Cardinal): LongBool; stdcall;
function pdfReadImageResolutionEx(const IPDF: PPDF; Buffer: Pointer; BufSize: Cardinal; Index: Cardinal; var ResX, ResY: Cardinal): LongBool; stdcall;

Purpose. Read the embedded DPI (dots-per-inch) resolution metadata of an external image file/buffer, without loading it into the document.

Description. Both ResX/ResY are pre-seeded to 72 (the PDF/print default) before parsing begins, so a format lacking DPI metadata (or a parse failure past the initial file-existence/buffer-non-empty check) still leaves the output at a sane default rather than 0. A/W read the whole file first; Ex parses the caller's buffer directly. Index is accepted by all three but not documented as reaching the underlying ApiReadImageDPI parser with any per-frame effect beyond whatever that parser's own multi-frame handling does internally — treat multi-frame (e.g. multi-page TIFF) DPI reading as returning the first frame's resolution regardless of Index, consistent with this chapter's other Index-ignoring insertion functions (Image Insertion and Replacement).

Parameters.

ParameterDescription
IPDFAccepted but not consulted for document state (pure file/buffer parse).
FileName / Buffer,BufSizeThe image to inspect.
IndexFrame index — not verified to have any effect; treat as always reading the first frame.
ResX, ResYOutput: DPI values, pre-seeded to 72 before parsing.

Return value. True if the file/buffer was read and DPI metadata parsed; False if the file doesn't exist / buffer is empty, or ResX/ ResY is a null pointer.

C# (P/Invoke)

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

Core

Exported names

pdfReadImageResolutionEx

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.