<% ' AutoImageSize - Aspect Ratio Guides Demo ' by Michael Kennedy ' http://www.unitedbinary.com ' mkennedy@unitedbinary.com set Resizer = Server.CreateObject ("ImageSize.AutoImageSize") ' Without registering, this will load a bit slow since there are so many ' images and each call to ChangeImageSize() gives a 2 second delay. ' These are the symbolic constants used. Call them whatever you want but the guides ' none,auto,width,height correspond to 0,1,2,3 respectively. ASPECT_RATIO_GUIDE_NONE = 0 ASPECT_RATIO_GUIDE_AUTO = 1 ASPECT_RATIO_GUIDE_WIDTH = 2 ASPECT_RATIO_GUIDE_HEIGHT = 3 ' Note: You'll need to replace the image files ' C:\Inetpub\wwwroot\images\wide.jpg ' C:\Inetpub\wwwroot\images\tall.jpg ' in the script with files that exist on your ' machine to run this page. %>

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:


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: Resizer.ChangeImageSize("C:\wide.jpg",50,350) => 350x232
Function call: Resizer.ChangeImageSize("C:\tall.jpg",50,350) => 148x350

<% Resizer.SetAspectRatioGuide ASPECT_RATIO_GUIDE_AUTO%> "> ">


Guide = NONE
Function call: Resizer.ChangeImageSize("C:\wide.jpg",350,50) => 350x50
<% Resizer.SetAspectRatioGuide ASPECT_RATIO_GUIDE_NONE%> ">


Guide = WIDTH
Function call: Resizer.ChangeImageSize("C:\wide.jpg",100,1) => 100x66
Function call: Resizer.ChangeImageSize("C:\tall.jpg",100,1) => 100x235
<% Resizer.SetAspectRatioGuide ASPECT_RATIO_GUIDE_WIDTH%> "> ">


Guide HEIGHT
Function call: Resizer.ChangeImageSize("C:\wide.jpg",1,300) => 452x300
Function call: Resizer.ChangeImageSize("C:\tall.jpg",1,300) => 127x300
<% Resizer.SetAspectRatioGuide ASPECT_RATIO_GUIDE_HEIGHT%> "> ">


Download the Code

Have a look for youself: AutoImageSizeAspectGuideExpo.asp


<% set Resizer = nothing%>