mum

EWWW Image Optimizer

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:

  1. 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.
  2. 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:

  1. 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.
  2. 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.

Download EWWW Image Optimizer

Download gifsicle

Download optipng

30 comments

30 comments on “EWWW Image Optimizer

  1. Daan Brusse on said:

    Dear Shane, on wordpress plugin you are using the same txt as CW, if i were you i would edit it. It says ‘EWWW Image Optimizer requires jpegtran, optipng, and gifsicle (imagemagick). You are missing: optipng, gifsicle.’, why not put some links to those add-ons in there? :) Cause i have no idea how to install them lol

    Good luck! Greets :)

    • Hmm, good point. I was thinking people would follow the Installation instructions on the plugin page, but I suppose you’d never see that page if you installed the plugin from within WP (which is probably what most people would do). Would it be better to just have links to each tool, or a single link to the Installation instructions (or maybe both)?

  2. Added some extra links to the Settings page, and the Installation instructions. Check out version 1.0.2 to see it in action

  3. Hi Shane,

    Love what is being said about what it will do. I do have one question,though.

    After uploading a file which is 982kb, in the WP Media Library it says it is reduced by 100% and the size is 982kb. But… it is still the same size…?

    Also when I then use it as a background image and on the internet I right click for the file size, it is said that it is scaled from 1600×937 to 1246×730 but the size is 982kb…

    Does it load faster or not? What is the advantage here? I don’t understand. Can you please explain it to me?

    Thanks and kind regards,
    DJ

    • Not sure what is going on there, sounds like there was some issue and it returned a 0 for the size of the new image accidentally. The 982kb that you’re seeing on the Media Library page is the amount reduced. Would be nice to see the final size though, I think I’ll put that on my future features plan. I would try the Re-optimize link and see what it does this time. If it gives you the same message, we’ll want to investigate a little deeper to see what’s going on.

  4. Markus on said:

    THX. This plugin simply deleted all my images and made the file size 0. :-/ No backup for the last two days. To bad right?

    • Unfortunately, that’s pretty much true. One of the changes I plan to make in the next release is to ensure that the new image was actually created for jpegs (instead of an empty file). As far as I know, the only way this happens is if someone doesn’t have jpegtran installed, and tells the plugin to skip the utils check. If you’ve found a different scenario, please let me know, as it ought to be fixed also. As you probably noticed, someone else seems to have had a similar issue (but just with one image), although they never gave much for details as to what they did either.

  5. Hi Shane,

    Re-optimizing did not give a different result and maybe my host doesn’t have jpegtran installed. But as I haven’t checked the box to skip the utils check, I assume that if the latter was the case I would have been notified…?

    I was testing the plugin for a friend and luckily am not desperately needing to have it working myself.

    Thanks and kind regards!

    • If you did not have jpegtran installed, it should have alerted you when you activated the plug-in, and on the Settings page. Can you test it out with 1.0.6 and see if it does anything different?

  6. I’ve installed the new version 1.06 and indeed now I see that in the Media Library it is said that jpegtran is missing…

  7. Well, that confirms half of my suspicions. I think the Bulk Optimize tool is the other half of the culprit, in that it either doesn’t check the utilities properly, or it couldn’t because of the PHP errors I fixed in 1.0.6. I’ll be doing some more testing for 1.0.7 (due out today or tomorrow).

  8. Hi Shane,

    I installaed EWWW plugin on my site, when I did bulk optimize, it first says I have 98 images but when started it just showed me running like 7-8 files and that’s it?

    Wouldn’t it be a good idea to have like progress bar or loading image showing percentage perhaps when it started doing bulk optimize?

    Cheers.

  9. That sounds like the operation is timing out. You may need to increase the max execution time in PHP. I think the default is usually 30 seconds, which is probably not going to be enough for a Bulk Optimize on 98 images.

    You could also try running smaller batches at a time via the Media Library page. There is a Bulk Optimize action in the drop-down menu which lets you run it on selected groups of images.

    Lastly, you can visit the Media Library to see which images were optimized. Based on your comment, you should only see 7 or 8 images that have results, whereas the rest would say that they have not been optimized yet.

  10. I would like to point EWWW at my Grand Flash Gallery image directory, how do I do this.

    The plugin works very well on media library.

    Thanks

    • The way the plugin works, you can’t just point it at arbitrary directories. If you’re familiar with the command line, you could use the commands for each tool on the FAQ to optimize those images. If you create a support request for this issue on the plugin support page ( http://wordpress.org/support/plugin/ewww-image-optimizer ) I’ll consider it a feature request to add integration for Grand Flash Gallery.

  11. Thx for that I will create a request as you say

  12. Hi
    I have installed EWWW and can bulk optimise in the media library. Does EWWW have an option to bulk optimise images in the galleries I have created. The only bulk option I can find in galleries is resize, I can see “optimise” in blue text on the right hand side under the thumbnail image but it looks like I have to individually optimise each image.
    Also how do I optimise the images as I upload them.
    Thanks
    Ray

  13. Ray again
    using Nexgen gallery
    ta

  14. Hi. This is probably a dumb question, but I’m having a hard time getting the optimizer to identify the locations of optipng and gifsicle. Perhaps I’ve put them in the wrong spot?

    I have shared hosting and I put them in the home folder.

    Could you let me know what the filepath should look like?

    thanks.

  15. Hey Ray & Tom, please post your questions over in the support forum, so that other users can benefit from the answers: http://wordpress.org/support/plugin/ewww-image-optimizer

  16. Pingback: in my mind's zen garden | wisdom through digital enlightenment

  17. Pingback: Vier Monate Keinehosensonntag: Zwerge auf den Schultern von Riesen - Keinehosensonntag

  18. Hi Shane,

    When I upload an image in my Media Library it comes up with “HTTP Error” and won’t show the file I have uploaded. I have to deactivate the plug-in, then upload an image, then activate the plugin again.

    Do you know why I would be getting this error?

    • That sounds like the bug I just fixed last night in 1.4.2. If you are still having trouble after upgrading to that version, please post in the plugin support forum.

  19. Kelley on said:

    Hi Shane,

    After your most recent update, all of my thumbnails have been changed! They used to have a maximum width/height of 150, but maintained their original dimensions. Now they are all cropped to exactly 150×150, and that is NOT what I wanted!

    (I did find an option under Settings > Media where a box was checked to crop thumbnails to those exact dimensions. I am NOT the one who checked this box on! I have since UNchecked it, but my thumbnails are still showing up as 150×150 boxes.)

    Is there any way to change them back? Any help would be greatly appreciated.

    • I can guarantee you that my plugin did not change your media settings. It doesn’t ever resize ANYTHING, even during a bulk operation. Even using the conversion options which aren’t all lossless, it never changes the image size. There is absolutely no code in the plugin to enable that.

      Is there any way to change them back? Probably. I’ve never used it, but you can try this plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/

      • Kelley on said:

        Hmm, super weird. Thanks for the reply and the explanation! I guess I’ll have to do some more digging. Thanks again (and sorry for the false accusation!).

  20. I’ve tried to optimize images through the bulk optimize and also in the media library. Both ways get errors before they optimize. Any idea what could cause this?

    • Also, when I try to upload an image I get an http error… I would love to use this plugin but I will have to disable it until I get a response. Hopefully you can help. Thanks..

    • Generally it is a javascript conflict. Try disabling plugins, and see if you can track down the culprit. Also, make sure you are using the latest version of the plugin, it has some extra sanity checking on the javascript includes.

Leave a Reply

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

*

HTML tags are not allowed.