54

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.

0

4 Answers 4

50

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.

3
  • Thanks to your post I understood that the unities given in page are not absolute, but related to the density. The page size in inches is the page_length_parameter / density Sep 23, 2019 at 15:00
  • 5
    For people who just want a PDF file made of their images, where the PDF page matches the image size and shape: convert -page 1678x1048 slide*.png presentation.pdf where 1678x1048 is the WIDTHxHEIGHT of your images in pixels. Oct 22, 2019 at 17:47
  • 1
    This cripples the image by resampling it into 72 dpi instead of keeping its input resolution. Dec 21, 2021 at 15:00
14

I just succeeded with convert file.mng -page letter file.pdf

2
  • 3
    This won't scale (shrink/expand) each image to optimally fit on page size. Feb 10, 2018 at 17:47
  • 5
    For European sizes it's -page a4, for landscape... well. try -rotate 90
    – JPT
    Jul 30, 2018 at 10:29
9

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
6
  • That resulted in a distorted, more square-ish aspect ratio, and the page size says 1.32x1.02 inch.
    – mackstann
    Jul 27, 2012 at 20:55
  • Which version of IM are you using? (run convert -version to find out) Jul 27, 2012 at 21:04
  • How did you determine the page size as being '1.32x1.02 inch' ? Jul 27, 2012 at 21:05
  • It's 6.5.7-8 on Ubuntu. I actually managed to muddle with -density to get the document size close enough to letter size. With -density 109, the pages end up around 606-617pts wide and 793pts tall, which evince accepts as being close enough to call it US Letter.
    – mackstann
    Jul 27, 2012 at 21:08
  • 1
    And for readers not in the US, who will likely be unfamiliar with 'postscript points', 'inches' and 'Letter': the United States has its own anachronistic system of lengths, and its own paper sizes, too. But you can use Google to convert to the 'postscript points' that ImageMagick uses, e.g. search for '297mm in postscript points' to eventually arrive at -resize 842x595. However, most standard paper sizes also work, e.g. -resize A4. May 1, 2015 at 6:26
0

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 for A4R will be 842x595

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.