[poppler] Image Resolution check
Andreas Zwinkau
beza1e1 at web.de
Sat Jul 30 03:44:05 PDT 2011
I want to check the resolution of images within pdfs. I made myself an
OutputDev class, which should perform the check in the drawImage
method (and alike). Here is the function, which is called for the
check:
void checkResolution(int width, int height, GfxState *state) {
double device_width, device_height;
state->transform(1.0,1.0,&device_width,&device_height);
printf("drawImage %dx%d -device->
%.0fx%.0f\n", width, height, device_width, device_height);
}
PDF 1.7 Spec says in §4.2.1: "All images are 1 unit wide by 1 unit
high in user space, regardless of the number of samples in the image."
Therefore i thought, the GfxState::transform method called with (1,1)
should give me the size of the image on the output device.
The calculated values in device_height and device_width adapt
according to the resolution i give to displayPages, but they seem to
be off.
Some example output with small logos for 300 DPI:
drawImage 119x119 -device-> 2386x3343
drawImage 192x192 -device-> 2346x3380
drawImage 118x118 -device-> 2362x3390
drawImage 118x118 -device-> 2362x3390
Some data with 72 DPI fed into displayPages:
drawImage 119x119 -device-> 573x802
drawImage 192x192 -device-> 563x811
drawImage 118x118 -device-> 567x814
drawImage 118x118 -device-> 567x814
I would have expected something close to the original pixel size for
the 72 DPI case.
Would the 119x119 image really have to be rendered to 573x802 pixels
for a 72 DPI OutputDev?
In another example, the ratio seems to be off:
drawImage 1162x256 -device-> 1345x1971
drawImage 262x997 -device-> 2272x1962
The images are not (significantly) transformed in the pdf compared to
the originals.
What did i do wrong?
--
Andreas Zwinkau
More information about the poppler
mailing list