How to create an image handler to resize external images on the fly

This post is about creating an image handler to resize external images on the fly. I got code to resize images with in our server, but i was in need to resize external images in the fly. So I modified the code. Lets create a generic handler file first, named ImageHandler.ashx.

Usage:

We can do this with our internal images also by changing the GetImage() function a little bit.
Hope you like this, enjoy coding

Cheers

3 thoughts on “How to create an image handler to resize external images on the fly

  1. Nathanael Jones

    Noticing the 50% white border around the resulting images yet? You need to set TileFlipModeXY in an ImageAttributes instance. Also, why not use Enum.Parse instead of the massive chain of IF statements?

    Last, you should probably check out http://imageresizing.net/ for a secure implementation that doesn't let everyone relay images through your domain, and has disk caching support.

    Reply
  2. GUIguy

    I noticed you set a noImageURL value but never use it. I'd like to see your code check to see if the intended image exists and if not show the noImageURL in its place as well as display this if the "image" query doesn't exist.

    Reply

Leave a Reply

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