Batch convert images to PDF
Tags convert, imagemagick
Recently (within the past year) I have helped a user with a problem converting hundreds of images into individual PDF files. I was pleasantly surprised to find imagemagick to effortlessly do this.
Command line tool imagemagick does what you need if they're images.
Installation:
Usage: (coverts all images into one pdf)
Usage: (converts each image into an individual pdf)
This is if you want .jpg to be replaced with .pdf. This command will work with any image. Replace .jpg with whatever image extension you want.
Here is the previous command but a little simpler. This is if you want the file extension to be .jpg.pdf.
Here's your bulk solution for converting all image files to pdf individually...
As you can see with a little bit of terminal ninja scripting you can get the job done relatively effortlessly. (search shell script howto in google)
Command line tool imagemagick does what you need if they're images.
Installation:
Code:
sudo apt-get install imagemagick
Code:
convert *.jpg foo.pdf
This is if you want .jpg to be replaced with .pdf. This command will work with any image. Replace .jpg with whatever image extension you want.
Code:
IFS=$'\n';for x in `ls -w 1 *.jpg`;do convert $x `echo $x | sed 's/\.jpg$/.pdf/'`;done
Code:
IFS=$'\n';for x in `ls -w 1 *.jpg`;do convert $x $x.pdf;done
Code:
IFS=$'\n';for x in `ls -w 1 *.jpg *.jpeg *.png *.gif *.tif *.tiff`;do convert $x $x.pdf;done
Total Comments 1
Comments
-
My examples listed above are a pile of crap. Here's a better way of doing the above.
For JPG images,
Code:for x in *.jpg;do convert "${x}" "${x%.jpg}.pdf";done
Posted 08-03-2013 at 09:50 AM by sag47