Conversion of PDF to JPG not so successful

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
mpc_kiddo123

Conversion of PDF to JPG not so successful

Post by mpc_kiddo123 »

I have a script called shatterpdf that is suppose to shatter a pdf into multiple jpg images.
However, it seems to crash the computer after a while.
I have tried to do different things to the script, but it seems to be hit-and-miss on various conversions.
I know the pdftk burst part works, but the imagemagick conversion part tends to crash.
Is there a way I can prevent crashes yet still get the pdfs to convert.

In general, I truly do have some scans turned pdf that are 600x600 density.
At other times, I have compiled PDFs with images that are definitely not 600x600.
I'd like to create a universal script for both occassions if possible.
The PDFs that are 600x600 can be about 135MB and take some time to convert: they also lead to a possible crash.

Here we go:

#!/bin/sh
#
#
# This script takes a large .pdf file with multiple pages
# and it shatters it into individual images.
# Each image is a page; and they will become .jpg unless
# otherwise specified...
mkdir ./temporary
mv ./*.pdf ./temporary
cd ./temporary
pdftk ./*.pdf burst output ../page000%d.pdf
cd ..
rm -R ./temporary
# CHANGE THE DENSITY AS REQUIRED
convert -quality 50 -density 600x600 -limit memory 32 -limit map 64 ./*.pdf ./page%d.jpg
rm ./*.pdf
exit
Post Reply