Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 977

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
<!--- This example shows how to specify the height and width of an image in pixels. --->
<cfimage source="../cfdocs/images/artgallery/jeff01.jpg" action="resize" width="100"
height="100" destination="jeff01_sm.jpg">
<!--- This example shows how to specify the height and width of an image as percentages. --->
<cfimage source="../cfdocs/images/artgallery/jeff02.jpg" action="resize" width="50%"
height="50%" destination="jeff02_sm.jpg">
<!--- This example shows how to specify the height of an image in pixels and its width as a
percentage. Notice that this technique can distort the image. --->
<cfimage source="../cfdocs/images/artgallery/jeff03.jpg" action="resize" width="50%"
height="100" destination="jeff03_sm.jpg" overwrite="yes">
The
tag requires that you specify both the height and the width for the
cfimage
The
tag
action uses the
cfimage
resize
of performance). For faster display, use the
Using the ImageResize function
The
function is like the
ImageResize
specify a value for 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. 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
function also lets you specify the type of interpolation used to resize the image. Interpolation lets
ImageResize
you control the trade-off between performance and image quality. By default, the
interpolation method. To improve performance (at the cost of image quality), change the
highestQuality
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
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#">
Note: Increasing the blur factor reduces performance.
For a complete list of interpolation methods, see ImageResize in the CFML Reference.
Using the ImageScaleToFit function
To create images of a uniform size, such as thumbnail images or images displayed in a photo gallery, use the
function. You specify the area of the image in pixels. ColdFusion resizes the image to fit the square
ImageScaleToFit
or rectangle and maintains the aspect ratio of the source image. Like the
interpolation, as the following example shows:
interpolation method for the best quality image (at the cost
highestQuality
function or the
ImageResize
tag
action. To ensure that the resized image is proportional,
cfimage
resize
Last updated 1/20/2012
action.
resize
function.
ImageScaleToFit
function uses the
ImageResize
highPerformance
function, you can specify the
ImageResize
972
form

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents