User Guide Cancel

ImageCreateCaptcha

 

Description

Create a Completely Automated Public Turing test to tell Computers and Humans Apart (CAPTCHA) image, a distorted text image that is human-readable, but not machine-readable, used in a challenge-response test for preventing spam.

Returns

Image object

History

ColdFusion 10: Added this function.

Syntax

imageCreateCaptcha (height, width, text)
imageCreateCaptcha (height, width, text)
imageCreateCaptcha (height, width, text)
imageCreateCaptcha (height, width, text [, difficulty])
imageCreateCaptcha (height, width, text [, difficulty])
imageCreateCaptcha (height, width, text [, difficulty])
imageCreateCaptcha (height, width, text [, difficulty, fonts, fontsize])
imageCreateCaptcha (height, width, text [, difficulty, fonts, fontsize])
imageCreateCaptcha (height, width, text [, difficulty, fonts, fontsize])

See also

cfimage

Properties

   

Parameter

Description

height

Required. Height in pixels of the image.

width

Required. Width in pixels of the image.

text

Required. Text string displayed in the CAPTCHA image. Use capital letters for better readability. Do not include spaces because users cannot detect them in the resulting CAPTCHA image.

difficulty

Optional. Level of complexity of the CAPTCHA text. Specify one of the following levels of text distortion:

  • low
  • medium
  • high

font

Optional. One or more valid fonts to use for the CAPTCHA text. Separate multiple fonts with commas. ColdFusion supports only the system fonts that the JDK can recognize. For example, TTF fonts in the Windows directory are supported on Windows.

fontsize

Optional. Font size of the text in the CAPTCHA image. The value must be an integer. The default size is 24.

Example

<h1>ImageCreateCaptcha Method</h1>
<cfset funcimg1 = ImageCreateCaptcha(35,400,"loner")>
<cfimage action="writetoBrowser" source="#funcimg1#">
<cfset funcimg2 = ImageCreateCaptcha(35,400,"loner","high")>
<cfimage action="writetoBrowser" source="#funcimg2#">
<cfset funcimg3 = ImageCreateCaptcha(35,400,"loner","high","serif,sansserif", "24")>
<cfimage action="writetoBrowser" source="#funcimg3#">
<h1>ImageCreateCaptcha Method</h1> <cfset funcimg1 = ImageCreateCaptcha(35,400,"loner")> <cfimage action="writetoBrowser" source="#funcimg1#"> <cfset funcimg2 = ImageCreateCaptcha(35,400,"loner","high")> <cfimage action="writetoBrowser" source="#funcimg2#"> <cfset funcimg3 = ImageCreateCaptcha(35,400,"loner","high","serif,sansserif", "24")> <cfimage action="writetoBrowser" source="#funcimg3#">
<h1>ImageCreateCaptcha Method</h1> 
<cfset funcimg1 = ImageCreateCaptcha(35,400,"loner")> 
<cfimage action="writetoBrowser" source="#funcimg1#"> 
<cfset funcimg2 = ImageCreateCaptcha(35,400,"loner","high")> 
<cfimage action="writetoBrowser" source="#funcimg2#"> 
<cfset funcimg3 = ImageCreateCaptcha(35,400,"loner","high","serif,sansserif", "24")> 
<cfimage action="writetoBrowser" source="#funcimg3#">

Get help faster and easier

New user?