Tuesday, 25 June 2013
HP MicroServer N54L
Just bought one of these tiny servers at work and am really impressed with it!
I have listed below the components I have put into the server:
16Gb (2 x 8Gb) 1333MHz DDR3 Non-ECC CL9 DIMM Memory (Kingston KVR13N9K2/16)
HP P410/256MB RAID Controller
4 x WD Red 1TB 3.5" SATA (In RAID 5) 2.7Gb usable
1 x StarTech.com 5.25in Trayless Hot Swap Mobile Rack for 3.5in Hard Drive
I re purposed the 250Gb hard disk that was supplied with the server in a trayless hot swap rack that fits in the 5.25" optical drive bay. This is the boot disk for the server.
The existing cable that connects the back plate on the drive bays in the server can be disconnected from the internal RAID controller and connected to the HP P410.
I have installed ESXi 5.1 onto the boot disk and will be running 2 virtual servers on it (both Centos 6 web servers).
The processor is about the same spec as a few G5 ML115 servers I have been hosting the same sites on so it should be fine.
The plus side is that this server is now fully hardware RAID5 and takes up a fraction of the space/power that the older servers did.
I can see me getting more of these servers set up at work and have been looking into having one at home as an offsite backup for work (loaded with larger hard disks though).
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!"
Counting the number of colour pages in a PDF with Ghostscript
Using Centos and Ghostscript (9.05 and above):
I am developing a print on demand solution at work and came up against an issue where I wanted to to be able to inspect a PDF file and work out where the colour pages appeared (if at all).I am using Centos 5 as the production servers but this solution should work on any Linux system running Ghostscript 9.05 or above.
Ghostscript 9.05 is required as you need access to the inkcov device to be able to work out the ink coverage for each of the CMYK plates.
Now I had to make the assumption that if C=M=Y that the page had 4 colour grey/black on it rather than it being a colour image. This may not be a 100% foolproof method but it was the only way I could think of determining if the page was colour or greyscale.
Anyway, here is the script I came with:
gs -o - -sDEVICE=inkcov test.pdf | grep -v "^ 0.00000 0.00000 0.00000" | awk '{if($1~/Page/){lastpage=$2;} if($1!~/Page/ && $1~/0./ && ($1!=$2 && $1!=3) && $1!=0.00000){ print lastpage}}'
Basically the command queries the PDF and ignores the lines returned where CMY are 0.
AWK is then used to ignore the lines that are irrelevant and print only the page number for the pages which were determined to be colour.
Subscribe to:
Posts (Atom)