Solved

Resize image with ASP.NET

Posted on 2014-03-28
5
330 Views
Last Modified: 2014-03-28
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.
0
Comment
Question by:SimpleDude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39961520
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39961585
Be sure to add in a reference to System.Drawing.dll in order for Carl Tawn's code to work  = )
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39961596
A reference to the System.Drawing assembly should be included by default, but it won't do any harm to double check ;)
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39961613
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
 

Author Closing Comment

by:SimpleDude
ID: 39961625
Thanks!
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question