I need a code that will allow me to resize images, but with the following functionality:
1) resize image upon upload
2) Resize image proportionally by specifying
Although it seems like you should be able to copy and paste a snippet to do this, there are a ton of pitfalls you need to look out for if you're building your own image resizing system. It's better to use a proven, tested, and supported open-source library.
To resize to a file directly from HttpPostedFile, call
ImageBuilder.Current.Build(httpPostedFile, "img.jpg", new ResizeSettings("width=200&quality=90"));
To resize an existing file, call
ImageBuilder.Current.Build("orig.jpg", "img.jpg", new ResizeSettings("width=200&quality=90"));
The ImageResizing.Net library is free, and MIT-licensed (no worries about licensing problems).