ASP.NET 2005: Resize image proportionally?

I have an image control I'm using on a webform that uses a URL to fetch images.  I need to resize images to a maximum of 200x200...however, I want them to be properly proportioned.

For example, an image that is 400x200....in order to fit within my maximum range of 200x200 would have to be resized to 200x100

whats the best way to do this?
arthurh88Asked:
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.

Craig WagnerSoftware ArchitectCommented:

Dim wOrig As Integer = imgOrig.Width
Dim hOrig As Integer = imgOrig.Height
 
If wOrig > hOrig Then
  wThumb = 200
  hThumb = hOrig / (wOrig / 200)
Else
  wThumb = wOrig / (hOrig / 200)
  hThumb = 200
End If

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
arthurh88Author Commented:
Dim wOrig as integer = ImgOrig.Width doesn't work as it says that the values are in units.  I have to use Dim wOrig As Unit  but then if I do that, I am unable to perform wOrig/200

0
Craig WagnerSoftware ArchitectCommented:
In the original code, imgOrig was an Image object, and the Width property was in pixels. You'll need to figure out how to get the width in pixels for your image.
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.