Adobe COLDFUSION 9 Manual page 967

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
The
action writes the file to the specified destination, which can be an absolute or relative path. The following
write
example shows how to create a ColdFusion image from a URL and write it to a file on the local storage drive:
<cfimage source="http://www.google.com/images/logo_sm.gif" action="write"
destination="c:\images\logo_sm.gif">
Specify the destination for the write action.
When you specify a
destination
Otherwise, ColdFusion generates an error:
<cfimage source="#myImage#" action="write" destination="images/jeff01.jpg" overwrite="yes">
Using the ImageNew function
You create a ColdFusion image with the
following example creates a ColdFusion image variable named "myImage" from the jeff01.jpg source file:
<cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")>
This line produces the same result as the following code:
<cfimage source="../cfdocs/images/artgallery/jeff01.jpg" name="myImage">
As with the
tag, you can specify an absolute or relative path, a URL, or another ColdFusion image as the
cfimage
source. In the following example, ColdFusion reads a file from the local drive and passes it to the
which writes the image to a new file:
<cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")>
<cfset ImageWrite(myImage,"myImageTest.png")>
The following code produces the same result:
<cfimage source="../cfdocs/images/artgallery/jeff01.jpg" name="myImage">
<cfimage source="#myImage#" action="write" destination="myImageTest.png">
Also, you can create a blank image. When using the
image. However, you can specify the width and height, respectively. The following example shows how to create a
blank canvas that is 300 pixels wide and 200 pixels high:
<cfset myImage=ImageNew("",300,200)>
Optionally, you can specify the image type, as in the following example:
<cfset myImage=ImageNew("",200,300,"rgb")>
Other valid image types are
argb
ColdFusion. For examples, see
Also, you can use the
ImageNew
file paths, and URLs. The following example creates a ColdFusion image from a JPEG file (x), and then creates another
ColdFusion image (y) from the image in memory:
<cfset x = ImageNew("c:\abc.jpg")>
<cfset y = ImageNew(x)>
For more information about the
Creating an image from a binary object
You can use the
tag to write an image file to ColdFusion variable. Then, you can pass the variable to the
cffile
function to create a ColdFusion image from the binary object, as the following example shows:
ImageNew
, set the
attribute to "
overwrite
function the same way you define a ColdFusion variable. The
ImageNew
ImageNew
and
. You can use blank images as canvasses for drawing functions in
grayscale
"Creating
watermarks" on page 973.
function to create ColdFusion images from other sources, such as Base64 bytearrays,
function, see the CFML Reference.
ImageNew
Last updated 8/5/2010
" to write to the same file more than once.
yes
function, you do not specify the source to create a blank
962
function,
ImageWrite

Advertisement

Table of Contents
loading

Table of Contents