Adobe COLDFUSION 9 Manual page 972

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
<!--- Create a ColdFusion image named "myImage" from a file uploaded to the server. --->
<cfimage action="read" source="#fileUpload.serverFile#" name="myImage">
<!--- Determine whether the file is greater than 300 pixels in width or height. --->
<cfif ImageGetHeight(myImage) gt 300 or ImageGetWidth(myImage) gt 300>
<!--- If the file exceeds the size limits, delete it from the server. --->
<cffile action="delete" file="#fileUpload.serverDirectory#/#fileUpload.serverFile#">
<cfoutput>
<!--- Display the following message. --->
<p>
The image you uploaded was too big. It must be less than 300 pixels wide and 300 pixels
high. Your image was #imageGetWidth(myImage)# pixels wide and
#imageGetHeight(myImage)# pixels high.
</p>
</cfif>
For information about retrieving image metadata, see the ImageGetEXIFTag, ImageGetIPTCTag, and ImageInfo
functions in the CFML Reference.
Compressing JPEG images
To reduce the size of large files, you can convert a JPEG file to a lower quality image by using the
tag. Specify a value between 0 (low) and 1 (high) for the
cfimage
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" action="write"
destination="jeff05_lq.jpg" quality="0.5" overwrite="yes">
You can perform the same operation by using the
<cfset myImage=ImageNew("jeff05.jpg")>
<cfset ImageWrite(myImage,"jeff05_lq.jpg","0.5")>
Manipulating ColdFusion images
You can perform a few common manipulation operations on ColdFusion images. For more information on
manipulating ColdFusion images, see the CFML Reference.
Adding borders to images
To create a simple border, use the
border:
<cfimage source="../cfdocs/images/artgallery/jeff01.jpg" action="border" thickness="5"
color="blue" destination="testMyImage.jpg" overwrite="yes">
<img src="testMyImage.jpg">
The border is added to the outside edge of the source image. This increases the area of the image.
To create complex borders, use the
ImageWrite
tag. The following example creates a ColdFusion image with a 5-pixel blue
cfimage
function. The following example shows how to nest borders:
ImageAddBorder
Last updated 8/5/2010
attribute, as the following example shows:
quality
function:
967
action of the
write

Advertisement

Table of Contents
loading

Table of Contents