Maintenance of this project has ended, as full feature parity and URL compatibility has been implemented in the newer ImageResizing.Net project, which is freely supported and updated on a weekly basis. In addition, users have not responded with any feedback after a multi-month call for maintenance release suggestions and bug reports.

Existing users can use the ImageHandlerSyntax plugin to migrate their websites to the ImageResizing.Net project while changing only their Web.config file, keeping all their existing image URLs intact.

If you have patches you would like to contribute to the Web Image Resize Handler project, we will accept them until July 2012. Please open tickets in the Issue Tracker for bugs, or start a new discussion for a non-bugs. You may also contact support@imageresizing.net.

Thanks,
Nathanael Jones
December 8, 2011


Efficient web based image resizer, rotater, formatter, zoomer and greyscaler handler for asp.net written in C#.

An asp.net extensible generic handler for processing images using filters. 5 filters are available: resize, zoom, rotate, greyscaling and formatting(jpg, gif, tif, png).

I have added 2 more encoding libraries for producing smaller images. They are the build in WPF bitmap encoders and the FreeImage library. FreeImage produces the smallest images in my tests, and is now the default bitmap encoder in the demo web app.

Uses an ImageProvider abstracted by the IImageProvider interface for getting original images, for example images can be retrieved from a CMS, database, disk or whatever. One IImageProvider has been implemented that reads files from disc. The src parameter in the url specified a key to lookup correct image. You can defined it to whatever fits your need.

Uses an ImageStore abstracted by IImageStore interface, to enable storage of already processed images in order to speed up image loading. Basically it is a cache store. By default a File System IImageStore has been implemented. In can be whatever fits your need.

Uses image processing class abstracted by IImageTool interface. If you wish to uses some fancy image processing libraries, for example a image library that produces better quality resized images than windows can produce. By default an implementation of IImageTool is NativeImageTool, that uses Windows API for image processing.

Uses Image Filters abstracted by the IImageFilter interface for image processing/filtering. Currently there are the following filters:
  • GreyScaleFilter
  • ResizeFilter
  • RotateFilter
  • ZoomFilter

By default is handles the following url parameters:

src: Key to an image, can be a relative url, guid or whatever you want

width: Width in pixels without any unit specification

height: Height in pixels without any unit specification

format: Formats to output to one of the image formats: png, gif, jpg, tif

greyscale: any non empty value triggers grey scaling

rotate: Invariant Culture floating point number in degrees where 360 is a complete rotation.

zoom: Invariant Culture floating point number indicating scale value. If 2 is specified the output will be double the original size.

Parameters can be combined as needed.


Sample Url's (only for illustration, they don't really work)

// Returns the image mapping to /bla.jpg resized to width of 100 pixels preserving aspect relative to height
http://webimageresizer.codeplex.com/ImageHandler.ashx?src=/bla.jpg&width=100

// Returns the image mapping to /bla.jpg resized to height of 100 pixels preserving aspect relative to width
http://webimageresizer.codeplex.com/ImageHandler.ashx?src=/bla.jpg&height=100

// Returns the image mapping to /bla.jpg resized to width 100 pixels and a height of 50 pixels
http://webimageresizer.codeplex.com/ImageHandler.ashx?src=/bla.jpg&width=100&height=50

// Returns the image mapping to /bla.jpg resized to 2.5 times the original size
http://webimageresizer.codeplex.com/ImageHandler.ashx?src=/bla.jpg&zoom=2.5

// Returns the image mapping to /bla.jpg resized to 2.5 times the original size and rotated 45 degrees,
http://webimageresizer.codeplex.com/ImageHandler.ashx?src=/bla.jpg&zoom=2.5&rotate=45

// Returns the image mapping to /bla.jpg resized to 2.5 times the original size, rotated 45 degrees and greyscaled
http://webimageresizer.codeplex.com/ImageHandler.ashx?src=/bla.jpg&zoom=2.5&rotate=45&greyscale=1

The cache uses the url as a key, so it cannot distinguish between url parameters order, different parameter order means different keys.

Enjoy

Last edited Jan 5, 2012 at 6:57 PM by NathanaelJones, version 9