Linux: Compile several JPGs into single PDF

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 338
Joined: Tue Nov 12, 2013 2:05 am

Linux: Compile several JPGs into single PDF

Post by peter_b »

Here's an ImageMagick command that takes several input images (e.g. PNG, JPG, etc) and creates a single PDF with each image on one page.
This is great to quickly and easily resize and "package" images to send by e-mail, for example.

Here's the basic command:

Code: Select all

$ convert *.jpg -resize 1000x1000 -compress jpeg -density 72 -units PixelsPerInch -quality 65% output.pdf
Parameters explained:
  • -resize 1000x10000: Scale the image to max. 1000 pixels (width or height). Aspect ratio is preserved.
    Another option might be "-resize 50%" to scale relatively.
  • -compress jpeg: Apply jpeg compression (=lossy!). There are other options available.
  • -quality 65%: Quality parameter for JPEG compression.
  • -density 72: Set to 72 DPI. This is useful if different image sources (with different DPIs) were used. 72 is for screen-display. Use at least 300 for printing.
  • -units PixelsPerInch: Without this setting, the density may not be calculated identically for image sources with different properties. If you end up with a PDF where different pages have different dimensions, try to add this :)
    (Thanks to Stackoverflow answer by Kenny)

Thanks ImageMagick developers! :D
Post Reply