Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 974

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 create a CAPTCHA image with the text "rEadMe" and write the
image directly to the browser. --->
<cfimage action="captcha" fontSize="25" width="162" height="75" text="rEadMe"
fonts="Verdana,Arial,Courier New,Courier">
Note: For the CAPTCHA image to display, the
characters specified in
text
ColdFusion 9 supports CAPTCHA images in PNG format only.
Note: If you specify the
destination
image files so that when multiple users access the CAPTCHA images, the files are not overwritten.
The following example shows how to create CAPTCHA images with a high level of text distortion.
<!--- Use the GetTickCount function to generate unique names for the CAPTCHA files. --->
<cfset tc = GetTickCount()>
<!--- Set the difficulty to "high" for a higher level of text distortion. --->
<cfimage action="captcha" fontSize="15" width="180" height="50" text="rEadMe"
destination="readme#tc#.png" difficulty="high">
For a detailed example, see
"Using CAPTCHA to verify
The following image shows three CAPTCHA images with low, medium, and high levels of difficulty, respectively:
Using the ImageDrawText function
To create a text image by using the
the location of the beginning of the text string. You can draw the text on an existing image or on a blank image, as the
following examples show:
<!--- This example shows how to draw a text string on a blank image. --->
<cfset myImage=ImageNew("",200,100)>
<cfset ImageDrawText(myImage, "Congratulations!",10,50)>
<cfimage source="#myImage#" action="write" destination="myImage.png" overwrite="yes">
<img src="myImage.png">
<!--- This example shows how to draw a text string on an existing image.
--->
<cfset myImage2=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")>
<cfset ImageDrawText(myImage2,"Congratulations!",10,50)>
<cfimage source="#myImage2#" action="write" destination="myImage2.png" overwrite="yes">
<img src="myImage2.png">
In the previous examples, the text is displayed in the default system font and font size. To control the appearance of
the text, you specify a collection of text attributes, as the following example shows:
<cfset attr = StructNew()>
<cfset attr.style="bolditalic">
<cfset attr.size=20>
<cfset attr.font="verdana">
<cfset attr.underline="yes">
To apply the text attributes to the text string, include the attribute collection name in the
In the following examples, the
value must be greater than:
width
times 1.08. In this example, the minimum
attribute to write CAPTCHA images to files, use unique names for the CAPTCHA
membership" on page 979.
function, specify the text string and the x and y coordinates for
ImageDrawText
text attribute collection applies the text string
"attr"
Last updated 1/20/2012
times the number of
fontSize
is 162.
width
ImageDrawText
"Congratulations!"
969
definition.
:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents