Adobe COLDFUSION 9 Manual page 970

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
To create a clone, you can pass a ColdFusion image variable to the
<!--- Use the ImageNew function to create a ColdFusion image from a JPEG file. --->
<cfset myImage=ImageNew("../cfdocs/images/artgallery/paul01.jpg")>
<!--- Turn on antialiasing to improve image quality. --->
<cfset ImageSetAntialiasing(myImage)>
<!--- Use the Duplicate function to create three clones of the ColdFusion image. --->
<cfset cloneA=Duplicate(myImage)>
<cfset cloneB=Duplicate(myImage)>
<cfset cloneC=Duplicate(myImage)>
<!--- Create a grayscale version of the image. --->
<cfset ImageGrayscale(cloneA)>
<!--- Create a thumbnail version of the image. --->
<cfset ImageScaleToFit(cloneB,50,"")>
<!--- Create an enlarged version of the image. --->
<cfset ImageResize(cloneC,"150%","")>
<!--- Write the images to files. --->
<cfset ImageWrite(myImage,"paul01.jpg","yes")>
<cfset ImageWrite(cloneA,"paul01_bw.jpg","yes")>
<cfset ImageWrite(cloneB,"paul01_sm.jpg","yes")>
<cfset ImageWrite(cloneC,"paul01_lg.jpg","yes")>
<!--- Display the images. --->
<img src="paul01.jpg">
<img src="paul01_bw.jpg">
<img src="paul01_sm.jpg">
<img src="paul01_lg.jpg">
Also, you can use the
cfimage
<!--- Use the cfimage tag to create a ColdFusion image (myImage) and make a copy of it
(myImageCopy). --->
<cfimage source="../cfdocs/images/artgallery/paul01.jpg" name="myImage">
<cfimage source="#myImage#" name="myImageCopy">
<!-- Use the ImageNew function to make a copy of myImage called myImageCopy2. --->
<cfset myImageCopy2 = ImageNew(myImage)>
Converting images
ColdFusion makes it easy to convert images from one file format to another. Also, you can convert an image file to a
binary object, BLOB data, or a Base64 string.
Converting an image file
The extension of the destination file determines the file format of the image. Therefore, to convert an image, simply change
the filename extension in the destination file. The following example shows how to convert a JPEG file to a GIF file:
"../cfdocs/images/artgallery/
<cfimage source=
Similarly, you can use the
ImageWrite
<cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")>
<cfset ImageWrite(myImage,"jeff01.gif")>
In both examples, the
convert
The
action does not create a ColdFusion image; it simply writes an image to a file. To convert an image and
write
generate a ColdFusion image variable, use the
tag and the
function to duplicate images, as the following example shows:
ImageNew
jeff01.jpg
function with the
ImageNew
action is implied.
action:
convert
Last updated 8/5/2010
function:
Duplicate
"
action="write" destination=
function:
965
"
"
jeff01.gif
>

Advertisement

Table of Contents
loading

Table of Contents