Solved

Resize image with ASP.NET

Posted on 2014-03-28
5
331 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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