Getting The URL Of ColdFusion 8's Temporary Images

<cffunction
	name="ImageGetUrl"
	access="public"
	returntype="string"
	output="false"
	hint="Returns the URL of the temporary image generated from the passed in ColdFusion image object.">
 
	<!--- Define arguments. --->
	<cfargument
		name="Source"
		type="any"
		required="true"
		hint="The ColdFusion image object who's URL we want to get."
		/>
 
	<cfargument
		name="Format"
		type="string"
		required="false"
		default="png"
		hint="The file type of the image we want to use."
		/>
 
	<!--- Define the local scope. --->
	<cfset var LOCAL = {} />
 
 
	<!--- Store the output of the image. --->
	<cfsavecontent variable="LOCAL.Output">
 
		<!--- Write the image the output buffer. --->
		<cfimage
			action="writetobrowser"
			source="#ARGUMENTS.Source#"
			format="#ARGUMENTS.Format#"
			/>
 
	</cfsavecontent>
 
 
	<!---
		Extract the URL of the temporary image. This will give
		us an array of the matches, which should only be one.
	--->
	<cfset LOCAL.URL = REMatch(
		"(?i)src\s*=\s*""[^""]+",
		LOCAL.Output
		) />
 
	<!---
		Clean up the SRC that we extracted. We can think of the
		value a double-quote delimited list in which our true
		SRC value is the last item.
	--->
	<cfset LOCAL.URL = ListLast( LOCAL.URL[ 1 ], """" ) />
 
	<!--- Return the URL. --->
	<cfreturn LOCAL.URL />
</cffunction>

For Cut-and-Paste