Resize image with ASP.NET

Hi. After a user uploads a PNG or JPG image by using the Fileupload control, is there a way to resize such image straight with ASP.NET (vb)?

Thanks.
SimpleDudeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Try something like the following - it's a little simplified, but shows the mechanics:
Dim image As System.Drawing.Image = System.Drawing.Image.FromStream(FileUpload1.FileContent)

Dim resized As System.Drawing.Image = New System.Drawing.Bitmap(image, New System.Drawing.Size(300, 200))
resized.Save("Somepath.png")

Open in new window

0
 
käµfm³d 👽Commented:
Be sure to add in a reference to System.Drawing.dll in order for Carl Tawn's code to work  = )
0
 
Carl TawnSystems and Integration DeveloperCommented:
A reference to the System.Drawing assembly should be included by default, but it won't do any harm to double check ;)
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Just throwing this into the mix :)

I use the component below in my classic asp pages, but the resizing part of it is written in vb.net, may be worth taking a look

http://www.imageresizing.quickersite.com/
0
 
SimpleDudeAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.