Google’s PageSpeed Insights can help you tweak your site’s accessibility by making things load faster. One way to make your website load faster is to optimize images.
Google suggests using Optipng for optimizing PNG or Portable Network Graphic files. There are a lot of ways to enable and use optipng, but I’m going to show you how to install it on your Dreamhost shared hosting server. Dreamhost doesnt automatically offer optipng, so until they do, it’s not that difficult to install it locally.
I would like to note here that since Optipng is not a persistent process, Dreamhost should have no trouble with us uploading and installing something that could facilitate faster web hosting.
You’ll need to know a little bit about using secure shell (ssh). I prefer to use putty.exe on windows. It’s even easier on mac and linux by just opening a terminal and ssh-ing into your preferred dreamhost user account.
Now that you have the binary compiled and properly installed locally, we can make it so your shell user can use the command by editing PATH.
Using libpng version 1.4.12 and zlib version 1.2.7-optipng
You are now ready to use optipng.
A typical usage of opting is thus:
$ optipng <filename>
This replaces the existing file with the compressed file. If you don’t need a backup that’s fine. Some people might like the “MORE POWER” approach, by further compressing images using the option -07 thus:
$ optipng -07 <filename>
This uses a lot of computer crunch time and is sort of rude to other users on a shared hosting system. If you’re going to use this on Dreamhost or another shared server system, use it sparingly on relatively small images. Do any large images at home on your own computer.
File size for the original file (1016 x 758) is 524K. After compression with optipng, the image is 255K (51.26% decrease). Yet the file looks identical to the original.
$ optipng optical-illusion-spinning.png
I hope this works for you!