Linux: Compile several JPGs into single PDF

Step-by-Step descriptions of how to do things.

Linux: Compile several JPGs into single PDF

Postby peter_b » Wed Mar 28, 2018 4:03 pm

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
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 302
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Return to HowTo's

Who is online

Users browsing this forum: No registered users and 2 guests

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: Google [Bot] and 8 guests

cron
Reputation System ©'