Solved

Resize image with ASP.NET

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

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 32

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now