Menu

Optimise your site with scheduled image optimisation

I have found a tool that loslessly reduces image sizes, and best of all, it can be scheduled via a cronjob as it is a Linux based solution.

The command I have used is imgopt.  It is a script that has been developed to optimise jpegs and pngs, reducing their file size while loosing no image quality.  It half the size of the images downloaded on a single page view for my site.

The tool uses a number of image manipulating tools to do the job.  optipng, jpegtran, pngout and advpng are all used to reduce the highest number of bytes possible from your jpegs and pngs.  To install all these options, use the installation instructions below and the ru the command imgopt [source folder/or wildcard *] to begin reducing the sizes of your images.

I think this has two distinct advantages.  The first being that it can be scheduled to occur via a cronjob during none peak hours, reducing the file sizes of User Generated Content (UGC) and the second being that it means you do not have to optimise images one by one like you would with the likes of Yahoo’s smush.it, which at the time of writing has no available API.

Give it a go and let me know what you think.  I found the script here - http://lyncd.com/2009/03/imgopt-lossless-optimize-png-jpeg/.  I should clarify that the below instructions are for a 64bit CentOS 5.5 installation so may differ for other distributions. Enjoy!

#INSTALLATION SCRIPT STARTS 
cd /tmp/
wget http://lyncd.com/files/imgopt-0.1.2.tar.gz
tar xfz imgopt-0.1.2.tar.gz
cd imgopt
sudo mv imgopt /usr/local/bin/
sudo chmod a+x /usr/local/bin/imgopt
sudo gcc -o jfifremove jfifremove.c
mv jfifremove /usr/local/bin/ 

#install rpmforge
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rm rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm 

#install optipng libjpeg advancecomp
yum -y install optipng libjpeg advancecomp

#install pngout
wget http://static.jonof.id.au/dl/kenutils/pngout-20110722-linux.tar.gz
tar xfz pngout-20110722-linux.tar.gz 
sudo mv pngout-20110722-linux/x86_64/pngout /usr/local/bin/ 

 

#INSTALLATION SCRIPT ENDS

#USAGE START
#imgopt *
# OR
#imgopt [FILE/DIR] [FILE/DIR] [FILE/DIR]
#OR
#imgopt *.png
#USAGE END

Comments

  • Much appreciated for the information and share!
    Nancy

  • gregk / October 20, 2011

    Installs fine. I didn’t see a huge filesize difference. The messages on complete seemed off: “*reduced 292 bytes to 300965 bytes*”

    I was hoping for big file diffs!

  • gregk / October 20, 2011

    I figured out the meaning of the messages. Thanks for posting the link in the article!

Post Comment

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>