Created
November 10, 2010 15:18
-
-
Save yura/670974 to your computer and use it in GitHub Desktop.
script to PDF to JPG using pdftk 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/bash | |
# Script to convert PDF file to JPG images | |
# | |
# Dependencies: | |
# * pdftk | |
# * imagemagick | |
PDF=$1 | |
echo "Processing $PDF" | |
DIR=`basename "$1" .pdf` | |
mkdir "$DIR" | |
echo ' Splitting PDF file to pages...' | |
pdftk "$PDF" burst output "$DIR"/%04d.pdf | |
pdftk "$PDF" dump_data output "$DIR"/metadata.txt | |
echo ' Converting pages to JPEG files...' | |
for i in "$DIR"/*.pdf; do | |
convert -colorspace RGB -interlace none -density 300x300 -quality 100 "$i" "$DIR"/`basename "$i" .pdf`.jpg | |
done | |
echo 'All done' |
Very Nice. Thanks
Simpler solution is to just use pdftoppm
:
pdftoppm -jpeg {pdf file} {output folder}
Install with sudo apt install poppler-utils
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for clearing that up!