Many of times we requires to create a thumbnails images or we can say we wants to create a new image from existing one with different height and width. to do so below code will help you:
First of all create an object of image class and pass image url in it:
Now create thumbnail:
Now save newly created thumbnail image to required format:
First of all create an object of image class and pass image url in it:
System.Drawing.Image objImage = System.Drawing.Image.FromFile(strFilename) ;
Now create thumbnail:
System.Drawing.Image.GetThumbnailImageAbort callback ; callback = null ; int shtWidth=180; int shtHeight=130; System.Drawing.Image objThumbnail = objImage.GetThumbnailImage(shtWidth , shtHeight, callback, System.IntPtr.Zero) ;
Now save newly created thumbnail image to required format:
objThumbnail.Save("thumbfilename", System.Drawing.Imaging.ImageFormat.Jpeg ) ;
No comments:
Post a Comment