Showing posts with label imagemagick. Show all posts
Showing posts with label imagemagick. 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 "---------------------------------------------------------"
Wednesday, 10 April 2013
Upgrade Ghostscript and Imagemagick on a Centos server
The following script can be used to remove a previous instance of Ghostscript and Imagemagick from a Centos based server and re-install the current versions.
A manual upgrade is required as the Centos repo does not currently have Ghostscript v9 (which is required to use the inkcov device example here).
#!/bin/bash
yum remove imagemagick -y
yum remove ghostscript -y
cd /tmp
wget http://downloads.ghostscript.com/public/ghostscript-9.07.tar.gz
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xf ghostscript-9.07.tar.gz
tar xf ImageMagick.tar.gz
cd /tmp/ghostscript-9.07
autoconf
./configure
make
make install
cd /tmp/ImageMagick
autoconf
./configure --enable-shared \
--with-modules \
--with-perl \
--with-x \
--with-threads \
--with-magick_plus_plus \
--with-gslib \
--with-wmf \
--with-lcms \
--with-rsvg \
--with-xml \
--without-dps
make
sudo make install
sudo ldconfig /usr/local/lib
cd /
rm -Rf /tmp/ghostscript-9.07
rm -Rf /tmp/ImageMagick
echo "Done!"
Subscribe to:
Posts (Atom)