Resizing image on the fly with ASP.NET using the System.Drawing namespace

Posted by Daniel - 587 Views

image resizing with asp.net,system drawing namespace,resizing image on the flyResizing image on the fly with the tradional ASP script is impossible without an external component. But with the release of the .NET Framework, resizing image on the fly has become an easy process.

The System.Drawing namespace provides all the functionalities to do that. Lets get to the point. Following is an example of a sub procedure to resize image and then save it to the specified path:

Sub ResizeThenSaveIt(strSourcePath as string, strSavePath as string, intWidth as integer, intHeight as integer)
Dim objOriginalImage as System.Drawing.Image
Dim objResizedImage as Bitmap
Dim imageFormat as Imaging.ImageFormat

objOriginalImage = System.Drawing.Image.FromFile(strSourcePath)
imageFormat = objOriginalImage.RawFormat
objResizedImage = New Bitmap(objOriginalImage, intWidth, intHeight)
objResizedImage.Save(strSavePath,imageFormat)
End Sub

Just in case you’re curious about how it works, the full code is included with this article, you can download it by clicking here (81 KB)

__________________________

Related posts brought to you by Yet Another Related Posts Plugin.

share this article

Digg del.icio.us Netscape StumbleUpon Yahoo! MyWeb reddit Furl Magnolia Newsvine Technorati SlashDot Blinklist Simpy Google
This post as PDFPosted in: Programming - January 2008


Leave a Reply


Options for your comment:





Get my Full Feed Here or you can subscribe to one of my category based feeds below:
Coffee Break

Latest Blog Entries

Categories

Neighbours and Friends

Comments - Thanks Guys :)

  • Therese Lachance: Hi, Any idea how to have ContuttoPDF fetch the correct page language?
  • Marlena Albu: Super Blog, Dude! I am constantly on the watch for new and interesting sites and postings about audio equipment… which is what...
  • tresloukadu: yo how did u fixed when the tags shows <? and it shows < “& l t ; ” ?? please send me an email.
  • Sean: This is a great piece of code and thanks for adding the updates. Sean’s last blog post: Not All Text Message Marketing Is Created...
  • rodhy: Thank for your code, it very usefull for me. best regard.