u n i t e d   b i n a r y - [AutoImageSize (Aspect Ratio Guide)]

Developer Tools
    HarnessIt Unit Test Framework
Web Components
    AutoImageEffects
    AutoImageInfo
    AutoImageSize
  home news products download support about

AutoImageSize - Aspect Ratio Guide Exposition

This page is a demonstration of the various modes of perserving the aspect ratio of an image during resizing (i.e. ChangeImageSize()). First an overview of the guides is presented, a sample of each of them in use follows and at the end you can download this page's ASP source.


The Guides

AutoImageSize 1.2+ implements the following aspect ratio guides:

  • Auto (aka Smart): [default mode] This guide is what you probably think of when you think of preserving the aspect ratio - in most cases. However, instead of just picking a dimension (width or height) and using that to determine the proper new image size, this guide does some smart comparision with the actual image.

    Suppose you have a 1000x500 image and you attempt to resize it to 50x200. This guide realizes that the larger dimension in the actual image is the width, whereas the larger dimension in the resize request is the height. To perserve the aspect ratio and accomadate your request as close as possible, this guide will switch the order of the new image dimensions and transform your call into a request for a 200x50 image.

    Next the guide considers the request for a 200x50 image with respect to the actual image dimesions of 1000x500. These are incompatible since 200/50 = 4 and 1000/500 = 2. Something has to give. The guide takes the maximum of the two new dimensions (max of 200 and 50) and uses that to resize the image and sets the smaller of the two to something accordingly. In this case, 200 > = 50 so the width of the new image will be 200 and to perserve the aspect ratio the height is set to 200*500/1000 = 100.

  • None: Just what is says. If you ask for a 200x50 image, you get a 200x50 image regardless of the original image's dimensions.

  • Width: This method uses only the width of the new image dimensions to determine the actual new image size. For example, with a 1000x500 image requesting a resize to 200x50 gives the new width of 200 and a new height of 200*500/1000 = 100.

  • Height: This method uses only the height of the new image dimensions to determine the actual new image size. For example, with a 1000x500 image requesting a resize to 200x50 gives the new height of 50 and a new width of 50*1000/500 = 100.


Guides in Action

Here's the various guides in action. We use two images one called wide.jpg and a second called tall.jpg. As the name indicates (and you'll see) wide.jgp is a little wider than tall, and tall.jpg is taller than wide.


Guide = AUTO
Function call: AIS.ChangeImageSize('wide.jpg',50,350) = > 350x232
Function call: AIS.ChangeImageSize('tall.jpg',50,350) = > 148x350


Guide = NONE
Function call: AIS.ChangeImageSize('wide.jpg',350,50) = > 350x50


Guide = WIDTH
Function call: AIS.ChangeImageSize('wide.jpg',100,1) = > 100x66
Function call: AIS.ChangeImageSize('tall.jpg',100,1) = > 100x235


Guide HEIGHT
Function call: AIS.ChangeImageSize('wide.jpg',1,300) = > 452x300
Function call: AIS.ChangeImageSize('tall.jpg',1,300) = > 127x300


Download the Code

Have a look for youself: AutoImageSizeAspectGuideExpo.asp


© 2001-2008 United Binary, LLC. All rights reserved.