Showing posts with label optimize. Show all posts
Showing posts with label optimize. Show all posts
Thursday, 25 April 2013
Speeding up Imagemagick convert by using it in conjunction with Ghostscript
Using the script below resulted in the Imagemagick convert taking 7.5 seconds, compared with the 2 pronged approach taking just over 0.5 seconds
#!/bin/bash
echo "---------------------------------------------------------"
echo "Use ImageMagick to convert PDF to 450x307 jpg"
echo "---------------------------------------------------------"
TT="$(date +%s%N)"
convert -resize 450x307 test.pdf test_resized.jpg
T="$(($(date +%s%N)-TT))"
# Seconds
S="$((T/1000000000))"
# Milliseconds
M="$((T/1000000))"
printf "Run time: %02d:%02d:%02d:%02d.%03d\n" "$((S/86400))" "$((S/3600%24))" "$((S/60%60))" "$((S%60))" "${M}"
echo "---------------------------------------------------------"
echo "Use Ghostscript to convert PDF to 450x307 jpg"
echo "---------------------------------------------------------"
TT="$(date +%s%N)"
gs -sDEVICE=jpeg -dNumRenderingThreads=4 -dNOGC -o test.jpg -dJPEGQ=95 test.pdf 2>&1
convert -resize 450x307 test.jpg test_resized.jpg
T="$(($(date +%s%N)-TT))"
# SecondsS="$((T/1000000000))"
# Milliseconds
M="$((T/1000000))"
printf "Run time: %02d:%02d:%02d:%02d.%03d\n" "$((S/86400))" "$((S/3600%24))" "$((S/60%60))" "$((S%60))" "${M}"
echo "---------------------------------------------------------"
Subscribe to:
Posts (Atom)