Properly Scaled Thumbnails

Generally we were required, in our classic ASP applications, to generate thumbnail images by using a 3rd party COM component. To do the same in the .NET Framework, you need not depend any more on those tools. It has built in functionality which will convert an original image to a thumbnail without ever writing a physical file to the hard disk. Of course, you have the option to save the result if you want. It will allow users to specify the width and height of the thumbnail image using a QueryString. It handles exceptions by throwing an image not found, in case you give a bad filename or invalid parameters. This code can be written within an aspx page, there is no need to use code behind.
Usage: http:///thumbnailimage.aspx?filename=&width=75&height=75 <img src="/thumbnailimage.aspx?filename=/gallery/MyUglyCat.jpg&width=120&height=120" border="0>
Where filename should be path relative to the root of the application folder. width & height are optional. If not specified, then the original width and height will be used. If width or height are specified as 0, then the default width / height of 100 pixels is used.

Author: Glypher
Catagory(s): ASP.NET ,Graphics ,VB.NET ,
Language: VB.NET
Type: Sample Pages
Posted: August 30, 2004
Date Revised:
Notes: By default the thumbnail image generated is of type JPEG. One can change the Response.Type by changing the following code.
Response.ContentType = ""image/jpeg""
thumb.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
'Change jpeg word with the required supported format(Gif, Png, Bmp etc).
Limitations:

Code / Download

Disclaimer: If you use any of the source code or compiled applications on this site, you realize that you do so AT YOUR OWN RISK. The items provided here are supplied AS IS and Veign makes no warranty as to its use or performance either expressed or implied.