Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I did something like

convert -page A4 -compress A4 *.png CH00.pdf

But the 1st page is much larger than the subsequent pages. This happens even though the image dimensions are similar. These images are scanned & cropped thus may have slight differences in dimensions

I thought -page A4 should fix the size of the pages?

share|improve this question

2 Answers

up vote 10 down vote accepted
+50

Last time I used convert for such a task I explicitly specified the size of the destination via resizing:

$ convert a.png b.png -compress jpeg -resize 1240x1753 \
                      -units PixelsPerInch -density 150x150 multipage.pdf

Where 1240x1753 are exactly DIN A4 when 150 DPI is chosen. I computed the values using bc and looked up the dimensions in inches in the Wikipedia article. The resize argument specifies the maximal page size.

This assumes that convert by default does not change the aspect ratio with the resize operation - which is the case:

Resize will fit the image into the requested size. It does NOT fill, the requested box size.

(ImageMagick manual)

Thus the -page a4 should be added, such that DIN A4 is specified in the PDF header:

$ convert a.png b.png -compress jpeg -resize 1240x1753 \
                      -units PixelsPerInch -density 150x150 \
                      -page a4 multipage.pdf

Update: Tested it again with another viewer, and it seems that one has to use -repage a4 instead of -page a4 to get the right page information into the resulting PDF.

share|improve this answer

What you really want to use is:

$ convert a.png b.png -compress jpeg -resize 1240x1753 \
                      -extent 1240x1753 -gravity center \
                      -units PixelsPerInch -density 150x150 multipage.pdf

-extentactually extends the image to be 1240x1753, while-resizekeeps the image's ratio, fitting it into either1240x...or...x1753`.

The -gravity parameter is optional but can be used to center the image when extending.

share|improve this answer
Thank you! -extent is really what I want to use :) -- please, add missed left quote in front of -extent, thanks! – brownian May 17 at 12:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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