Learning ColdFusion 8: CFImage Part III - Watermarks And Transparency

<!--- Read in the original image. --->
<cfset objImage = ImageRead( "./blue_eyes.jpg" ) />
 
<!---
	Read in the spacer image. This is the base 64 encoding
	of a 1x1 transparent spacer GIF. This will allow you
	to create a transparent canvas without having to have
	the spacer image on-hand. Here, I am putting in the
	base64 headers for demonstration (but they are not needed).
--->
<cfset objWatermark = ImageReadBase64(
	"data:image/gif;base64," &
	"R0lGODlhAQABAIAAAP///////yH5BAEHAAEALAAAAAABAAEAAAICTAEAOw=="
	) />
 
<!---
	Resize the transparent image to be the size of the
	target canvas. This will result in a larger,
	transparent canvas.
--->
<cfset ImageResize(
	objWatermark,
	190,
	30
	) />
 
<!---
	Set text drawing anti aliasing to be on. We are
	going to be writing text and then blurring it, so
	we want to let it be a little fuzzy.
--->
<cfset ImageSetAntialiasing(
	objWatermark,
	"on"
	) />
 
<!--- Set the drawing color to be white. --->
<cfset ImageSetDrawingColor(
	objWatermark,
	"##FFFFFF"
	) />
 
<!--- Create text attributes. --->
<cfset objAttributes = {
	Font = "Arial Black",
	Size = "20"
	} />
 
<!--- Draw the water mark text. --->
<cfset ImageDrawText(
	objWatermark,
	"Kinky Solutions",
	11,
	20,
	objAttributes
	) />
 
 
<!--- Blur the watermark image. --->
<cfset ImageBlur(
	objWatermark,
	6
	) />
 
 
<!---
	Set text drawing anti aliasing to be on for the
	target image. Since the image we are pasting in,
	we want a slight blurring.
--->
<cfset ImageSetAntialiasing(
	objImage,
	"on"
	) />
 
<!---
	Paste the manually created watermark image onto the photo.
	This time, we don't need to turn on any anti aliasing since
	the watermark has solid borders. The anti alisasing only
	helps us when the pasted image has anti aliased perimeter.
--->
<cfset ImagePaste(
	objImage,
	objWatermark,
	(objImage.GetWidth() - objWatermark.GetWidth()),
	(objImage.GetHeight() - objWatermark.GetHeight())
	) />
 
<!--- Write the image with the new watermark to the browser. --->
<cfimage
	action="writetobrowser"
	source="#objImage#"
	/>

For Cut-and-Paste