Why does DPI change from 94 to 72 DPI for PDF2Image output when I specify 90 degree rotation?

Skip to first unread message


Mar 18, 2016, 8:04:36 PM3/18/16

When I convert a 612x792 PDF page to image using the following settings, I get the expected DPI of 94.

Pdf2image o output hres 800 vres 1200 f jpg input.pdf

But when I rotate the PDF, I get a DPI of 72.

Pdf2image o output hres 800 vres 1200 r 90 f jpg input.pdf

Why is this?


This is because the image source width, height are flipped (due to rotation) but the hres, vres parameters are not.

So assuming your input.pdf is portrait orientated (taller than wider), and you specify portrait output (again taller than wider), then when calculating the scale/dpi, the width and height of the source are swapped, so the pdf is landscaped orientation, but the target is portrait, so it gets scaled smaller.

To keep the aspect ratio  the smallest scale adjustment is picked. Which in this case is

800 / 729 * 72

is about 72 DPI 

while the non-rotated is
800 / 612 * 72

which is about 94 DPI.

You might want to do image rotation after the generating the image, as that is a trivial process for an image manipulation tool. Or switch your hres, vres values when rotating by 90 or 270 degrees.
Reply all
Reply to author
0 new messages