DCSIMG
Visual Studio 2010 Image Optimizer Extension - Gil Fink's Blog

Gil Fink's Blog

Fink about IT

News

Microsoft MVP

My Facebook Profile My Twitter Profile My Linkedin Profile

Locations of visitors to this page

Creative Commons License

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2013 Gil Fink

Hebrew Articles

Index Pages

My OSS Projects

English Articles

Visual Studio 2010 Image Optimizer Extension

Visual Studio 2010 Image Optimizer Extension

One thing that caught my attention while vs2010 logo_thumb[1]watching the session that Mads Kristensen had in MIX11 was the Image Optimizer extension he is writing. This extension can be very valuable when you are trying to optimize your ASP.NET application (whether it is Web Forms or
MVC 3).

The Image Optimizer Extension

The extension adds the opportunity to use industry proven algorithms such as SmushIt and PunyPNG for optimizing the images in the solution. This is enabled by a new set of menu items that are being added when you use the right button click in the Solution Explorer. You can optimize a single image file or an entire images folder. The optimization won’t affect the quality of the images so you don’t need to be afraid to use it. The currently supported image types for optimization are PNG, GIF and JPEG. In order to use the extension go to the extension manager and search the Image Optimizer in the online gallery. Another way is to download the Image Optimizer extension and install it.

Lets look at a use case scenario:
Optimize Images Menu Item_thumb[3]

As you can see in the figure above, I point to the images directory inside my ASP.NET MVC 3 project and then I use the Optimize images menu item to optimize the images. The optimization summary will be written in the Output Window:
Optimization in Output Window_thumb[3]

Another feature that the extension is supporting, currently in beta, is the ability to convert images to base64 strings for stylesheet embedding. Embedding base64 strings instead of using the image Url can decrease the amount of HTTP requests that your application produces. This of course should be used with caution since creating base64 strings from images should be done on small images. In big images the produced string can be very long and you will get a slower download rate for your web page.
Here is a use case scenario for base64 strings for stylesheet embedding:
Base64 Embedding_thumb[4]

In the stylesheet file place the mouse on the image Url and use the Embed image in stylesheet menu item in order to replace the Url into a base64 string. The output of this operation:

div 
{
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAABkCAYAAAD0ZHJ6AAAAXElEQVRo3u3OAQ0AAAgDIO3f5CW1hnOQgE4ydVgLCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKfgkubNIrSDutzqcAAAAASUVORK5CYII=)
}

Summary

The Image Optimizer extension is a promising extension if you are looking to optimize your application. It can help to reduce the size of the images you use or to embed small images as a base64 string in the stylesheet. I encourage you to play with it and see whether it can help you in your current or next application.

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# May 14, 2011 4:24 PM

Visual Studio 2010 Image Optimizer Extension – Gil Fink on .Net | Learn Visual Studio said:

Pingback from  Visual Studio 2010 Image Optimizer Extension – Gil Fink on .Net | Learn Visual Studio

# May 14, 2011 9:29 PM

Visual Studio 2010 Image Optimizer Extension – Gil Fink on .Net said:

Pingback from  Visual Studio 2010 Image Optimizer Extension – Gil Fink on .Net

# May 16, 2011 4:22 AM

Cassette - Asset management for .NET web apps said:

Pingback from  Cassette - Asset management for .NET web apps

# August 31, 2011 11:02 AM