• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

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?
  • 2
1 Solution
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)
  wThumb = wOrig / (hOrig / 200)
  hThumb = 200
End If

Open in new window

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

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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now