EasyCaptcha() For Multi-Image CAPTCHA Creation

<cffunction
	name="EasyCaptcha"
	access="public"
	returntype="array"
	output="true"
	hint="Outputs a CAPTCHA problem using a series of images rather than one image.">
 
	<!--- Define arguments. --->
	<cfargument
		name="Text"
		type="string"
		required="true"
		hint="The text that will be output in the CAPTCHA."
		/>
 
	<cfargument
		name="FontSize"
		type="string"
		required="false"
		default="20"
		hint="The font size to use for the CAPTCHA."
		/>
 
	<cfargument
		name="BackgroundColor"
		type="string"
		required="false"
		default="##FAFAFA"
		hint="The canvas color."
		/>
 
	<cfargument
		name="Color"
		type="string"
		required="false"
		default="##333333"
		hint="The drawing (Text) color."
		/>
 
	<!--- Define the local scope. --->
	<cfset var LOCAL = {} />
 
	<!--- Set the font properties. --->
	<cfset LOCAL.FontProperties = {
		Font = "Courier New",
		Size = ToString( ARGUMENTS.FontSize ),
		Style = "normal"
		} />
 
 
	<!---
		Create the array in which we are going to store the
		individual images. Each image will represent a single
		characer in the CAPTCHA.
	--->
	<cfset LOCAL.Images = [] />
 
 
	<!--- Loop over the characters in the given text. --->
	<cfloop
		index="LOCAL.CharacterIndex"
		from="1"
		to="#Len( ARGUMENTS.Text )#"
		step="1">
 
		<!--- Get character. --->
		<cfset LOCAL.Character = Mid(
			ARGUMENTS.Text,
			LOCAL.CharacterIndex,
			1
			) />
 
		<!--- Get character dimensions. --->
		<cfset LOCAL.Dimensions = THIS.GetTextDimensions(
			LOCAL.Character,
			LOCAL.FontProperties
			) />
 
		<!--- Create a new image. --->
		<cfset LOCAL.Image = ImageNew(
			"",
			(LOCAL.Dimensions.Width + 6),
			Ceiling( LOCAL.Dimensions.Height * 1.5 ),
			"rgb",
			ARGUMENTS.BackgroundColor
			) />
 
		<!--- Set the drawing color. --->
		<cfset ImageSetDrawingColor(
			LOCAL.Image,
			ARGUMENTS.Color
			) />
 
		<!--- Draw character on canvas. --->
		<cfset ImageDrawText(
			LOCAL.Image,
			LOCAL.Character,
			3,
			Ceiling( LOCAL.Dimensions.Height * 1.1 ),
			LOCAL.FontProperties
			) />
 
		<!--- Add the image to the return array. --->
		<cfset ArrayAppend(
			LOCAL.Images,
			LOCAL.Image
			) />
 
	</cfloop>
 
 
	<!---
		Create a local buffer to which to save the images. We
		are doing this so that we can strip out the white space
		between the individual images to make a cleaner output.
	--->
	<cfsavecontent variable="LOCAL.Buffer">
 
		<!--- Loop over images array. --->
		<cfloop
			index="LOCAL.Image"
			array="#LOCAL.Images#">
 
 
			<!--- Write character to response buffer. --->
			<cfimage
				action="writetobrowser"
				source="#LOCAL.Image#"
				format="gif"
				/>
 
		</cfloop>
 
	</cfsavecontent>
 
	<!--- Strip out all white space that is not in a tag. --->
	<cfset LOCAL.Buffer = Trim(
		REReplace(
			LOCAL.Buffer,
			"\s+(?=<)",
			"",
			"all"
			)
		) />
 
	<!--- Write the buffer out to the repsonse. --->
	<cfset WriteOutput( LOCAL.Buffer ) />
 
 
	<!--- Return image array. --->
	<cfreturn LOCAL.Images />
</cffunction>

For Cut-and-Paste