Creates a resized image with the aspect ratio maintained.
imageScaleTofit(name, fitWidth, fitHeight [, interpolation] [, blurFactor])
→ returns void
someImage.scaleTofit(fitWidth, fitHeight [, interpolation] [, blurFactor])
highestQuality (default)
highQuality
mediumQuality
highestPerformance
highPerformance
mediumPerformance
nearest
bilinear
bicubic
bessel
blackman
hamming
hanning
hermite
lanczos
mitchell
quadratic
1-10
This example shows how to resize an image to fit a 100x100-pixel square while maintaining the aspect ratio.
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage">
<!--- Turn on antialiasing to improve image quality. --->
<cfset imageSetAntialiasing(myImage,"on")>
<cfset imageScaleTofit(myImage,100,"","lanczos")>
<!--- Display the modified image in a browser. --->
<cfimage source="#myImage#" action="writeToBrowser">
CF 11+ Scale to fit an image to half its original size (71,71)
imgObj = imageRead("http://cfdocs.org/apple-touch-icon.png");
imgObj.scaleTofit(71,71);
cfimage(action="writeToBrowser", source=imgObj);
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.