Yay! PNGOUT – How to install on Dreamhost
PNGOUT is a wonderful little utility written by …. (of Duke Nukem fame) that compresses PNG files by about 15%-20% on average. Which if you have many PNG images in you website can make a small but noticeable difference in load times. Although there are other similar utilities PNGOUT seems to be regarded as the best so I decided to use it. Since I already had a lot of images I wanted to compress on this blog I had to figure out a couple of things to easily compress them.
- I wanted to run PNGOUT on my webhost server since then I wouldn’t have to transfer the files back and forth to compress them. Since Dreamhost has linux servers so that required finding a linux port of PNGOUT. As and added benefit this should make it reasonably simple to make a cron job to compress all PNG images later.
- I wanted to basically make it a one line command to compress all my PNG files so I had to figure out how to find all PNG images under a directory and run PNGOUT on them
Nothing particularly complex so lets dive in. Step one was easy as there is already a well know port of PNGOUT available although it took a bit of searching to find the download site. Now I just download the Linux Dynamic zip, unzip it and load up the i386 executable to my home directory on my webhost. (Make sure to make it executable)
After testing to make sure pngout worked on a single file I set about finding how to do it on all PNG files under a directory. Give that I am not a linux expert it was pretty easy as the find command let me do everything I wanted.
find blog_directory -name *.png -exec ./pngout {} \;
That will find anything under blog_directory that matches the naming pattern *.png and run pngout on it. That was easy enough I may actual setup a cron job sometime.