I know that ImageMagick's convert program can be used as follows to convert a collection of images -- say, in PNG format -- to a PDF file:

convert *png output.pdf

The problem with this is that each image is then stretched to fit on one page, whereas I would like to keep the original dimensions of the images and put as many as possible on one page in the PDF file before moving on to another page.

Any idea how to do that?


What you are trying to do, placing many images in one (PDF) page, is not trivial. Even the notion of "original dimension" of an image is no longer trivial, once something like PDF is involved. The dimension of an image is given in pixels, while PDFs have no idea about pixels. You have to mess around with stuff like dpi (dots per inch, or pixels per inch).

I suggest you look up some typsetting tools, like LaTeX.

  • Great idea, I just tried it although I was unsure it would be suitable, as I'm interested in automating the generation of the document and was afraid I would have to play around with various parameters, but it works perfectly. Thanks! – anon May 2 '11 at 12:04

As an alternative to LaTeX, you could combine the usage of imagemagick's montage to generate each page and then concatenate the resulting montages into a multi-page PDF.

The actual commands to run will depend on how variable the size of images is.

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.