Created
November 25, 2015 17:28
-
-
Save venam/114a325184cc6a17ed93 to your computer and use it in GitHub Desktop.
convert a list of pdfs to images of good quality
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/bash | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 pdfs" >&2 | |
exit 1 | |
fi | |
for pdf in "$@" | |
do | |
echo "Converting $pdf to images" | |
pages="$( pdfinfo "$pdf" |grep Pages | sed -e 's/Pages:\( \)\+//')" | |
dir="$( echo $pdf | sed -e 's/.pdf//')" | |
if [ -d $dir ]; then | |
echo "directory $dir already exists" | |
else | |
mkdir $dir | |
convert -density 150 "$pdf[0-$pages]" -quality 90 "$dir/page-%d.jpg" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment