Text To Image in Coldfusion 8
I just had a quick look today to find out how hard it is to write a "text to image" in Coldfusion 8. Turns out to be very easy. As is often the case in Coldfusion. If I left everything default, I could do it with just 3 simple lines. Here is the sample code:
[coldfusion]
<!--- Create a new empty image. --->
<cfset imgText = ImageNew("",200,20,"argb")>
<!--- Set the background color to black. --->
<cfset ImageSetBackgroundColor(imgText, "black")>
<!--- Clear the rectangle specified on myImage with the background color specified for the image. --->
<cfset ImageClearRect(imgText,0,0,200,20)>
<!--- Turn on antialiasing to improve image quality. --->
<cfset ImageSetAntialiasing(imgText)>
<!--- Set the drawing color to green. --->
<cfset ImageSetDrawingColor(imgText,"green")>
<!--- Set the attributes of the text --->
<cfset textattribs = StructNew()>
<cfset textattribs.font="Arial">
<cfset textattribs.size = 15>
<cfset textattribs.style = "bolditalic">
<!--- Draw the text. --->
<cfset ImageDrawText(imgText, "http://www.flogiston.be", 10, 15, textattribs)>
<!--- Write da image. --->
<cfimage action="writeTobrowser" source="#imgText#">
[/coldfusion]