How do I control PDF paper size with ImageMagick?

mackstann picture mackstann · Jul 27, 2012 · Viewed 25.7k times · Source

I have 16 jpg files which are around 920x1200 pixels (the widths slightly differ but heights are all 1200). I'm trying to join them into a pdf with:

convert *.jpg foo.pdf

But the resulting paper size is 1.53x2 inches. If I pass the arguments -page Letter, the page size ends up being a bewildering 1.02x1.32 inches. What is going wrong here? All of the information I can find suggests that this should work. I just want a document that consists of 16 letter-size pages.

Answer

Forest picture Forest · May 8, 2016

This question is pretty old, but I had a similar problem and I think I found the solution.

The documentation for the -page option says "This option is used in concert with -density", but the relationship between the options seems a little unclear, possibly because the documentation is geared towards raster images.

From experimenting with the settings, I found that the pdf page size can be controlled by combining -page -density and -units. The documentation for -page shows that letter is the same as entering 612 x 792. Combining -density 72 with -units pixelsperinch will give you (612px /72px) * 1in = 8.5in.

convert *.jpg -units pixelsperinch -density 72 -page letter foo.pdf should do what the original poster wanted.