The ImageResize function is similar to the cfimage tag resize action. To ensure that the resized image is proportional, specify a value for the either the height or width and enter a blank value for the other dimension:
<!--- This example shows how to resize an image to 50% of original size and resize it proportionately to the new width. Note that the height value is blank. ---> <cfset myImage=ImageNew("http://www.google.com/images/logo_sm.gif")> <cfset ImageResize(myImage,"50%","")> <!--- Save the modified image to a file. ---> <cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes"> <!--- Display the source image and the resized image. ---> <img src="http://www.google.com/images/logo_sm.gif"/> <img src="test_myImage.jpeg"/>
The ImageResize function also lets you specify the type of interpolation used to resize the image. Interpolation lets you control the trade-off between performance and image quality. By default, the ImageResize function uses the highestQuality interpolation method. To improve performance (at the cost of image quality), change the interpolation method. Also, you can set the blur factor for the image. The default value is 1 (not blurred). The highest blur factor is 10 (very blurry). The following example shows how to resize an image using the highPerformance form of interpolation with a blur factor of 10:
<cfset myImage=ImageNew("../cfdocs/images/artgallery/aiden01.jpg")> <cfset ImageResize(myImage,"","200%","highPerformance", 10)> <cfimage action="writeToBrowser" source="#myImage#">
For a complete list of interpolation methods, see ImageResize in the CFML Reference.