Google Search


Wednesday, August 22, 2007

ThumbNail Creation in ASP.Net

Creation of thumbnails from image in ASP.Net is very easy task.

Following are Steps to create thumbnails image in ASP.Net :

1)Read the Image using the method Image.FromStream() as,

Dim imInputImage, imThumbNail As Image

imInputImage = System.Drawing.Image.FromStream(imgUpload.PostedFile.InputStream)

here,imgUploadis the id of FileUpload Control.

2)Get the ThumbNail Image using the method GetThumbnailImage.

imThumbNail = imInputImage.GetThumbnailImage(100, 100, Nothing, System.IntPtr.Zero)

We can also specify the format of the Thumbnail image we want to save by,

imThumbNail.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)

Some of the Formats can be,
Jpeg- System.Drawing.Imaging.ImageFormat.Jpeg
Gif - System.Drawing.Imaging.ImageFormat.Gif
Tiff- System.Drawing.Imaging.ImageFormat.Tiff
Png - System.Drawing.Imaging.ImageFormat.Png