The following example shows how to draw an image in ColdFusion and use it as a watermark. You use the ImageSetDrawingStroke function to define the attributes of lines and shapes you create with drawing functions and the ImageSetDrawingColor function to define the color.
<!--- This example shows how to draw a red circle with a line through it and use it as a watermark. ---> <!--- Use the ImageNew function to create a ColdFusion image that is 201x201 pixels. ---> <cfset myImage=ImageNew("",201,201)> <!--- Set the drawing transparency of the image to 30%. ---> <cfset ImageSetDrawingTransparency(myImage,30)> <!--- Set the drawing color to red. ---> <cfset ImageSetDrawingColor(myImage,"red")> <!--- Create an attribute collection that sets the line width to 10 pixels. ---> <cfset attr=StructNew()> <cfset attr.width = 10> <!--- Apply the attribute collection to the ImageSetDrawingStroke function. ---> <cfset ImageSetDrawingStroke(myImage,attr)> <!--- Draw a diagonal line starting at (40,40) and ending at (165,165) on myImage. The drawing attributes you specified are applied to the line. ---> <cfset ImageDrawLine(myImage,40,40,165,165)> <!--- Draw a circle starting at (5,5) and is 190 pixels high and 190 pixels wide. The drawing attributes you specified are applied to the oval. ---> <cfset ImageDrawOval(myImage,5,5,190,190)> <!--- Create a ColdFusion image from a JPEG file. ---> <cfimage source="../cfdocs/images/artgallery/raquel05.jpg" name="myImage2"> <!--- Scale the image to fit in a 200-pixel square, maintaining the aspect ratio of the source image. ---> <cfset ImageScaleToFit(myImage2,200,200)> <!--- Paste the myImage2 directly over the myImage. ---> <cfset ImagePaste(myImage,myImage2,0,0)> <!--- Save the combined image to a file. ---> <cfimage source="#myImage#" action="write" destination="test_watermark.jpg" overwrite="yes"> <!--- Display the image in a browser. ---> <img src="test_watermark.jpg"/>