Creating Transparent Images With ColdFusion 8 And ImageNew()

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Createing A Transparent Canvas With ImageNew()</title>
 
	<style type="text/css">
 
		body {
			background-image: url( "striped_background.gif" ) ;
			}
 
		p {
			text-align: center ;
			}
 
		img {
			border: 3px solid #990000 ;
			}
 
	</style>
</head>
<body>
 
	<h1>
		Createing A Transparent Canvas With ImageNew()
	</h1>
 
 
	<!---
		We want to create a transparent canvas with
		ColdFusion 8's ImageNew() function. We are creating
		this image on the fly so we have no source image,
		hence the empty first argument. To create a transparent
		image, use the ARGB canvas type (the "A" stands for
		alpha and gives our canvas an alpha channel).
 
		NOTE: Leave out the 5th optional arguemnt, the canvas
		color in order to create a transparent canvas.
	--->
	<cfset imgCanvas = ImageNew(
		"",
		200,
		200,
		"argb"
		) />
 
	<p>
		<!--- Write to browser. --->
		<cfimage
			action="writetobrowser"
			source="#imgCanvas#"
			format="png"
			/>
	</p>
 
</body>
</html>

For Cut-and-Paste