[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Resize image with ASP.NET

Posted on 2014-03-28
5
Medium Priority
?
338 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 2000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

650 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