Jpeg optim install for increase server's speed

Share to Facebook Share to Twitter Share to Google Plus

Install jpegoptim in CentOS

If you’re an adsense publisher, you might have noticed the scorecard the middle-right side of the Adsense screen. It gives us valuable insight on how to improve the performance of our website. and one of the persistent Red flag I see for the sites I manage is the image optimization problem. Fortunately, Google is not just showing you the problem because they also throw some recommenddations to address the problem.

adsense-scorecard-optimize-image
For the case of the images, Google recommends to use image optimization tools to reduce the size of the file without losing the quality of the image. They call it loss-less optimization which can result anywhere between 10-50% reduction of file size.The most common recommended tool is the jpegoptim. However, it does not come witht he CentOS package so you have to download and compile it first. Anyway, installing is as simple as cut and paste.

But first, you have to install libjpeg first. It’s a library that’s being used by the tool to optimize the file.


yum -y install libjpeg

yum install libjpeg*

Once done, we can go ahead witht he installation of jpegoptim by downloading, compiling and installing the tool.

cd /tmp
mkdir jpegoptim
cd jpegoptim
wget http://www.kokkonen.net/tjko/src/jpegoptim-1.3.0.tar.gz
zcat jpegoptim-1.3.0.tar.gz | tar xf -
cd jpegoptim-1.3.0
./configure
make
make strip
make install

And now, start the optimization. Here’s the command to find all the jpeg files on your server.

find / -iregex '.*\.\(jpg\|JPG\|jpeg\|JPG\)' -type f -exec /usr/local/bin/jpegoptim {} ';'

And you’re done.

References:
Google Adsense
http://freecode.com/projects/jpegoptim
http://www.kokkonen.net/tjko/src/jpegoptim-1.3.0.tar.gz