I'm currently trying to take a PDF file, create images for each page in two different sizes with decent quality. I'm using GhostScript and Mogrify right now which seems to be doing pretty well but I'm wondering if there is anything I could be doing to "improve" it.
I have a file that is located in /tmp/ that has a random name and ends with the .tmp extension. So lets say the original PDF file is /tmp/8967867897687.tmp, I'd run this:
Code: Select all
/usr/bin/gs -sDEVICE=png256 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dDOINTERPOLATE -sOutputFile=/tmp/8967867897687.tmp.%d.xlarge -dSAFER -dBATCH -dNOPAUSE -r200% /tmp/8967867897687.tmp
Code: Select all
/usr/bin/mogrify -resize 600x -depth 8 -format large.png /tmp/8967867897687.tmp.*.xlarge
Code: Select all
/usr/bin/mogrify -resize 145x -depth 8 -format small.png /tmp/8967867897687.tmp.*.large.png
Code: Select all
/tmp/8967867897687.tmp.1.large.small.png
/tmp/8967867897687.tmp.2.large.png
/tmp/8967867897687.tmp.2.xlarge
/tmp/8967867897687.tmp.1.large.png
/tmp/8967867897687.tmp.1.xlarge
/tmp/8967867897687.tmp.2.large.small.png
Filenames don't matter at all since these are just temporary and I'll be renaming them when transferring them later on. The application I'm writing is in Java and I'm running these commands from Java.
Is this the correct way to do it? Is there anyway to make it any faster without losing image quality? Would it be faster to just run a loop and call convert for each page/thumbnail instead of mogrify?
Any suggestions / improvements would be greatly appreciated. Thanks in advanced.