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:
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.
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 = 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
Have a look for youself: AutoImageSizeAspectGuideExpo.asp
© 2001-2008 United Binary, LLC. All rights reserved.