Created
July 9, 2012 21:53
-
-
Save edingc/3079241 to your computer and use it in GitHub Desktop.
Batch Convert PDFs to JPEGs using the Poppler library and ImageMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
############################################################################## | |
#### | |
#### Convert PDFs to JPEGs using the Poppler library and ImageMagick | |
#### | |
#### This script converts a folder full of PDFs to JPEGs using libpoppler and | |
#### ImageMagick. In this case, PDFs are coverted at 150 dpi and outputted as | |
#### 85 percent quality JPEGs with a maximum width of 800 pixels. Edit these | |
#### values to suit your environment. | |
#### | |
#### To use the script, ensure the script is executable and navigate to a folder | |
#### of PDFs in the terminal and run: ./pdf2jpg.sh | |
#### | |
#### By: Cody Eding (cody@codyeding.com) | |
#### | |
############################################################################## | |
for i in *.pdf; do | |
filename=$(basename $i .pdf) | |
pdftoppm -r 150 $i > $filename.ppm | |
pnmtojpeg -quality 100 $filename.ppm > $filename.jpg | |
rm $filename.ppm | |
convert -quality 85% -resize '>800' $filename.jpg $filename.jpg | |
done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment