I have a folder full of jpg files. When I use the following command,

convert *.jpg assembly.pdf

I get a pdf file with one image per page of the pdf. I would like to put 9 images on each page. Is there a way to do this with convert or mogrify?

Alternatively, I'd like to combine 9 of the jpg images into one jpg image so that I can convert that into a PDF.




You're looking for montage from ImageMagick :

       montage  - create a composite image by combining several sepa‐
       rate images. The images  are  tiled  on  the  composite  image
       optionally adorned with a border, frame, image name, and more.

If you already have convert then you almost certainly also have montage. To get a grid of 3x3 images per page on your pdf try this:

 montage *.jpg -tile 3x3 assembly.pdf

This assumes your images all have roughly the same size. Have a read through the documentation for more complex options.

  • 2
    This was great! We used montage *.jpg -tile 3x3 -geometry 1000 assembly.pdf to get 9 high quality images per page. We tried it on a sample of 30 images or so, and it worked like a charm! Then we tried to run the full 400 images and... my computer started chirping and seizing, and it consumed 95% of the ram. Eventually we got the message "killed" in the terminal... probably we'll have to run this in batches! :) Anyway, thanks man! I'm going to read the docs in detail, because imagemagick seems like supreme command-line sorcery. – Ziggy Mar 11 '13 at 5:42
  • I suggest to montage the images into jpg first, and then convert the jpg into pdf. Somehow the size is exploded if you convert into pdf directly. – user3121260 Apr 22 '15 at 17:42

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.