Home > Blogs > Tags > Asp.net Create Image Thumbnails Blog Posts
Posted on November 1, 2011 0:28 AM by mediasoftpro. Tags: image handler , asp.net resize images , asp.net create image thumbnails

In this article we will provide information and sample codes for creating image handler file in asp.net, c# or vb.net which can be used to resize image, generate highest quality output and show image preview in real time.

You can directly use image handler in image src path to process and display output on browser.

Such handler file have lots of advantages, e.g

  • Provide ability to resize image in real time and display output on browser.
  • Protect image direct path from access.
  • Add lots of other validation to protect images from anti leeching.

Image handling have some drawbacks

  • Consume resources and performance issues so should be used in cases where its needed. e.g if you provide system for user to prepare image for mobile photo, iphone, psp, high definition, and according to different screen resolutions.

Handler file can be called as

<img src="imagehandler.ashx?filename=abc.jpg"...

Code for generating image handler.

GenerateThumbnail function will be used to generate highest possible quality output based on three paramters,

lcFilename (complete path of source photo), width (output width of photo), height (output height of photo)

Code is shown below

[code]private byte[] GenerateThumbnail(string lcFilename, int Width, int Height)
    {
        //Image img = Image.FromStream(fStream);
        //Image thumbnailImage = img.GetThumbnailImage(Width, height),
        //      new Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

     
complete story

© 2007 - 2012, mediasoftpro.com  | Site Map | Privacy Policy | Terms of Use