Creation of thumbnails from image in ASP.Net is very easy task.
Following are Steps to create thumbnails image in ASP.Net :
First Imports System.Drawing class
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
|
| Author: JithendraNadh 23 Nov 2007 | Member Level: Silver Points : 0 |
I have this piece of code:
Dim im, thumb As Image im = System.Drawing.Image.FromStream(imgUpload.PostedFile.InputStream) thumb = im.GetThumbnailImage(100, 100, Nothing, System.IntPtr.Zero) thumb.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
Im getting the error as:
System.NullReferenceException: Object reference not set to an instance of an object. at ThumbNail.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\JITHENDRA\My Documents\Visual Studio 2005\WebSites\WebSite1\ThumbNail.aspx.vb:line 14
|
| Author: amiya behera 02 Jun 2008 | Member Level: Bronze Points : 2 |
hi
i have save images in the database( sqlserver 2005) and also displying it in datalist. but i want to disply in datalist with thumbnail . can u give some idea or source code for it
|
| Author: amiya behera 02 Jun 2008 | Member Level: Bronze Points : 2 |
how make thumbnail dynamically for images which store in databse. its will be disply in datalist with thumbnail.how i will be do it, the code should be in c#, asp.net
|