Sitecore Image Optimizer module

This is going to be a very short one – I’m really too busy right now to spend time on doing a proper blog post. I hope I’ll manage to do an update soon.

I’ve just spent two hours creating an image optimization module that’s just submitted to Sitecore Marketplace. It will run pngcrush, jpegtran, or whatever image compression utility you prefer on your images in media library.

Since I shouldn’t redistribute pngcrush/jpegtran, you’d have to download those two exe files yourself and put them in a suitable location on your server. Just update the config file with the location of those files and you may also fiddle with the command line arguments to suit your needs.

Once installed, a Compress menu option will appear in the media ribbon. It will only be active for png and jpg images. Clicking compress will start the compression job.

The original file will be backed up into your configured backup folder. On a successful compression, i.e. the resulting file is smaller; the new file will be attached to the media item.
In the future, I’d like to do the same processing for resized images as well.

Sitecore Image Compression screenshot

Using this tool, the Android simulator background image that comes with a clean Sitecore setup, was shrinked from 112278 to 71138 bytes. That’s a reduction of almost 37% without any loss in image quality.

Download Image Optimizer-0.1.zip package.

Hope you like it!

15 thoughts on “Sitecore Image Optimizer module

    • Thank’s for the notify! Stupid me forgot to hit the publish button in Sitecore marketplace. It’s up for review now, so it’ll be there any time. (It’s really simple at this stage and I hope I get the time to do an improved version.)

      • No worries. It’s up there now. I’m about to give it an install and see how it goes. Will the package install insert the config elements I need?

      • Nevermind. I figured it all out. Works great. Number 1 feature request would be support running it over an entire folder. Number 2 would be to keep the popup visible to see the savings as it disappears for me in Chrome.

      • Sorry, I’m still having issues. Although I can see in the Sitecore backend that the media item says it is smaller, when I browse to that image via url and save that image it is still the original. Could this be a media cache thing?

        • It seems like the backup is created, the temporary image optimised is created but on replacement of existing media item image it updates the file but with the same image resulting image size. Timestamp is updated, size of image in the sitecore UI is updated, but image size is still original.

          Do you have an open source version of this anywhere that I can look at and submit a pull request? Seems like an issue with media.SetStream(newStream, extension); I am using filesystem media storage and running Sitecore v7. Thanks.

          • I know this was comment was left a long time ago but just mentioning a similar experience in case it helps others.

            I also used the compression and the UI was saying that the image has been optimized and the file size field was updated.

            However, on the front-end the image was still the uncompressed size.

            The solution? Publish the image(s)! Doh!

            This may have not been your issue but when using the compression wizard you do get the sense that it is already being published.

  1. When you take poladroid images they first appear scattered/movable over the desktop, ..i like this effect, but whenever you close the package/shut down, the iamges are saved to ‘my images’ as normal files. Is there a way to review the photos scattered over the desktop again?

  2. Our OpenEXR codec produces highest quality 64bpp RGBA floating point data (16 bits per components, with Alpha) and support many variants of the EXR format, including tiled images and several compression schemes. The codec reads all sample images supplied by ILM with the OpenEXR SDK. The codec uses processor-specific optimizations to speedup unpacking of zip-compressed EXR files. The current version also supports multi-resolution files and can extract lower resolution mipmap levels directly, through the IWICBitmapSourceTransform interface.

  3. Pingback: Using Dianoga for Image Optimization

  4. Hello,

    Thank you very much for this module! I have added some functionalities in your module. I have change the the compressor for png by pngquant wich is clearly more performant now. And I have added a wizard to compress a complete folder with or without the sub-folder. This wizard is optimized to not re-compress the already compress images.

    So is it ok for you if I release an updated version of this module? I will definitively put your blog and your original module in the references of course.

    Benjamin Vangansewinkel

    • Hi

      Sure, no problem. I’m happy you found this simple module useful and could add more functions to it! My intention was to do something similar, but never had the time to fulfil it. One thing that’s still on my todo-list is adding the compressor as plugin into the media stream, so that images that are resized runtime on CD-servers get compressed as well. (See my old blog post on large scale web apps)

      / Mikael

  5. Hi, I’m looking for “Image Renditions” in sitecore market place. I think, these features are same of that. Could you please help me?

    Many Thanks,
    Satish

  6. Keeping up with trends, techniques, what works and what doesn’t is a tough job, but lists like this make it so much easier to learn about image optimizer module.

    Thanks for including all interesting points to read and make us aware.

Comments are closed.