Resizing photos dynamically in ASP.NET and C#

I am looking for some code to get me started in resizing photos.  Users uploaded photos of any size, with just a restriction of 3 mb.  The height and width can be of any size.  So when the users click on the thumbnail of the image, their original photo is displayed and it usually is of a size that is bigger than the web browser and the users have to scroll horizontally and vertically to see the photo.  What I'm looking to do is resize/recrop the the photo so that it is more manageable to view.  I'd like to be able to open a popup web browser at a certain size, say 600 pixels, and have that as the base for the photo to be recropped around.  Obviously the photo can't be recropped to 600x600 or it would be distorted one way or another.  Any help would be appreciated.
Thanks in advance....
URSIMSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VelioCommented:
this function is one way of scaling an image.

should be fairly easy to calculate the scale you should be scaling at to get to a desired target width/height...

scale = targetWidth / originalWidth or targetHeight / originalHeight
        private Image ScaleImage(Image image, double scale)
        {
            Image result = new Bitmap(image, new Size((int)(image.Size.Width * scale), (int)(image.Size.Height * scale)));
            return result;
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
digital_thoughtsCommented:
There are a number of articles on how to accomplish what you are needing, here are just a few:

http://www.codeproject.com/KB/GDI-plus/imageresize.aspx

http://blog.paranoidferret.com/?p=11
0
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.