How do I control PDF paper size with ImageMagick?
LinuxPdfImagemagickLinux Problem Overview
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.
Linux Solutions
Solution 1 - Linux
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.
Solution 2 - Linux
I just succeeded with
convert file.mng -page letter file.pdf
Solution 3 - Linux
For Letter, you need to specify the size as 792x612 PostScript points. Therefor try this command:
convert \
in1.jpg \
in2.jpg \
in3.jpg \
in4.jpg \
in5.jpg \
-gravity center \
-resize 792x612\! \
letter.pdf
Works for me with ImageMagick version 6.7.8-3 2012-07-19 Q16 on Mac OS X:
identify -format "%f[%s] : %W x %H\n" letter.pdf letter.pdf[0] : 792 x 612 letter.pdf[1] : 792 x 612 letter.pdf[2] : 792 x 612 letter.pdf[3] : 792 x 612 letter.pdf[4] : 792 x 612
Or
pdfinfo -f 1 -l 5 letter.pdf Title: _ Producer: ImageMagick 6.7.8-3 2012-07-19 Q16 http://www.imagemagick.org CreationDate: Fri Jul 27 22:28:00 2012 ModDate: Fri Jul 27 22:28:00 2012 Tagged: no Form: none Pages: 5 Encrypted: no Page 1 size: 792 x 612 pts (letter) Page 1 rot: 0 Page 2 size: 792 x 612 pts (letter) Page 2 rot: 0 Page 3 size: 792 x 612 pts (letter) Page 3 rot: 0 Page 4 size: 792 x 612 pts (letter) Page 4 rot: 0 Page 5 size: 792 x 612 pts (letter) Page 5 rot: 0 File size: 178642 bytes Optimized: no PDF version: 1.3
Solution 4 - Linux
According to this, 72 dpi is the default density => one dot per pixel (for a computer screen).
So you just need to specify -units pixelsperinch
.
You can type the following command :
$ convert *.jpg -units pixelsperinch -page letter foo.pdf
BTW : If you want to use a non standard page size such as A4R for example, you must first determine the page size in dots (or pixels given at 72dpi) :
$ paperconf -s -p A4
595.276 841.89
Then the -page
argument will be 842x595