History (skip this section if you just don’t care)
This plugin started when I was on a quest to find an Image Optimizer plugin. I found two that looked pretty good: WP Smush.it and CW Image Optimizer. WP Smush.it has file size limitations, is a bit slow, and some people have an issue with their images being sent to Yahoo’s servers (even if Yahoo states they only store them temporarily). In practice, I didn’t care about the privacy issues, but I did have technical problems using WP Smush.it and only got it to work about 75% of the time. So it was down to CW Image Optimizer, and then I discovered it used littleutils for optimization. I’m on shared hosting, and it wasn’t installed. I looked around the littleutils site hoping for precompiled binaries, but found nothing. Then I looked at the dependency list, and it was long. Some of them would already be on my shared host, but I quickly discovered two that weren’t: pngcrush, and gifsicle. These are the programs that littleutils uses ‘under the hood’ to optimize PNGs and GIFs. It uses jpegtran for JPGs, which my host does have. This created two problems:
- I would need to compile several programs before I could even start on littleutils, and then I would need to install them in my /home folder since I’m on shared hosting. Once I had those compiled, I would have to figure out how to tell littleutils where I had put all the dependencies, since they wouldn’t be in the usual places. Not fun.
- Then, once I had compiled littleutils, it would still be in my /home folder. Uh-oh, CW Image Optimizer doesn’t let me tell it where I’ve installed the utilities. Bummer.
I had two possible solutions to my two problems:
- Compile everything, and then hack the CW Image Optimizer plugin with the appropriate paths. This would unfortunately render it impossible to upgrade in the future without re-editing the plugin code, something I try very hard to avoid.
- Create a derivative of CW Image Optimizer (since it is GPL3 after all) using the underlying tools that littleutils uses, and allow it to have configurable paths to the binary files of those tools.
I chose option two, because it also allows me to include some more flexibility in the future. For example, I already have an option to keep (by default) metadata for jpegs in case that information (comments and EXIF info) is important to you. I also chose optipng for PNG optimization which is a derivative of pngcrush. So, without further ado, I introduce to you:
The EWWW Image Optimizer
The EWWW Image Optimizer is a WordPress plugin that will automatically and losslessly optimize your images as you upload them to your blog. It can also optimize the images that you have already uploaded in the past.
Because EWWW Image Optimizer uses lossless optimization techniques, your image quality will be exactly the same before and after the optimization. The only thing that will change is your file size. The one small exception to this is GIF files. While the optimization is technically lossless, you will not be able to properly edit the image again without performing an –unoptimize operation with gifsicle.
The EWWW Image Optimizer plugin is based heavily on the CW Image Optimizer plugin, which in turn is based upon the WP Smush.it plugin. Unlike the WP Smush.it plugin, your files won’t be uploaded to a third party. Your files are optimized using the Linux [jpegtran](http://jpegclub.org/jpegtran/), [optipng](http://optipng.sourceforge.net/), and [gifsicle](http://www.lcdf.org/gifsicle/) image tools (available for free).
The primary reason for creating this plugin was that CW Image Optimizer uses littleutils. While littleutils is a fine piece of software, it does not do any of the optimization work itself, but simply calls upon other utilities with pre-configured options. The result is that you need to have these other utilities already installed to build/compile the binaries for littleutils. In contrast, EWWW Image Optimizer calls the optimization utilities directly (which may also allow us to offer more flexibility in the future). This is better suited to shared hosting situations where these utilities may already be installed. The programs we use (jpegtran, optipng, and gifsicle) generally have very minimal dependencies, so all you will need is a hosting account with shell access, and build utilities installed. You can then tell EWWW Image Optimizer where you compiled these utilities. I use Bluehost, which meets these requirements, and Dreamhost is another suitable alternative. There are likely others out there that I am not aware of.
Why use EWWW Image Optimizer (some of the same reasons for using CW Image Optimizer)?
- Your pages will load faster. Smaller image sizes means faster page loads. This will make your visitors happy, and can increase ad revenue.
- Faster backups. Smaller image sizes also means faster backups.
- Less bandwidth usage. Optimizing your images can save you hundreds of KB per image, which means significantly less bandwidth usage.
- Super fast. Because it runs on your own server, you don’t have to wait for a third party service to receive, process, and return your images. You can optimize hundreds of images in just a few minutes. PNG files do take a little longer than JPGs, as the plugin is currently configured to perform 10 optimization trials before selecting the best algorithm.
- Root access not needed. Because the paths are configurable via the settings page, and the programs we use have minimal dependencies, you can compile the utilities (if they aren’t already installed) and tell the plugin where they are located.