Whatever message this page gives is out now! Go check it out!

ImageSetDrawingTransparency

Last update:
May 18, 2026

Description

Specifies the degree of transparency of drawing functions.

Returns

Nothing.

Category

Function syntax

ImageSetDrawingTransparency(name, percent)

See also

History

ColdFusion 8: Added this function.

Parameters

Parameter
Description
name
Required. The ColdFusion image on which this operation is performed.
percent
Required. Percent of transparency:
  • 0 = opaque
  • 100 = transparent Decimal values are valid.

Usage

By default drawing images are opaque. Use this function to create watermarks or other translucent images. Use the ImageSetAntialiasing function to improve the quality of the rendered image.

Example

Example 1
--->
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfimage source="../cfdocs/images/artgallery/austin01.jpg" name="myImage">
<!--- Turn on antialiasing to improve image quality. --->
<cfset ImageSetAntialiasing(myImage)>
<!--- Set the drawing transparency to 40%. --->
<cfset ImageSetDrawingTransparency(myImage,40)>
<!--- Set the text drawing attributes. --->
<cfset attr = StructNew()>
<cfset attr.size = 40>
<cfset attr.style = "bold">
<!--- Specify the text string and the location of the text on the image.
--->
<cfset ImageDrawText(myImage,"SOLD!",40,100,attr)>
<!--- Display the image in a browser. --->
<cfimage source="#myImage#" action="writeToBrowser">
Example 2
--->
<!--- Create a ColdFusion image from a JPEG file. --->
<cfimage source="../cfdocs/getting_started/photos/somewhere.jpg" name="myImage" action="read">
<!--- Set the drawing transparency to 75%. --->
<cfset ImageSetDrawingTransparency(myImage,75)>
<!--- Create a ColdFusion image from a picture in the cfartgallery. --->
<cfimage source="../cfdocs/images/artgallery/raquel05.jpg" name="myImage2" action="read">
<!--- Set the drawing transparency to 30%. --->
<cfset ImagesetDrawingTransparency(myImage,30)>
<!--- Paste the ColdFusion log over the picture at coordinates (0,0).--->
<cfset ImagePaste(myImage,myImage2,0,0)>
<!--- Display the two source images and the result. --->
<cfimage source="#myImage#" destination="watermark.jpg" action="write" overwrite="yes">
<img src="../cfdocs/getting_started/photos/somewhere.jpg">
<Img src="../cfdocs/images/artgallery/raquel05.jpg">
<img src="watermark.jpg">
Example 3
<cfimage action="read" name="logo" source="../cfdocs/getting_started/photos/somewhere.jpg">
<cfset imageGrayscale(logo)>
<cfset imageRotate(logo,45)>
<!--- This code creates the ColdFusion image to be used as the base image.
--->
<cfimage action="read" source="../cfdocs/images/artgallery/raquel05.jpg" name="baseImage">
<!--- This code sets the drawing transparency for the base image to 80%.
--->
<cfset ImageSetDrawingTransparency(baseImage,80)>
<!--- This code pastes the watermark image onto the base image at the coordinates (0,0). --->
<cfset ImagePaste(baseImage,logo,0,0)>
<!--- This code writes the result to a file. --->
<cfimage action="write" source="#baseImage#" destination="abc_watermark.jpg" overwrite="yes">
<!--- This code displays the image used as a watermark and the result. --->
<img src="../cfdocs/getting_started/photos/somewhere.jpg"/>
<img src="abc_watermark.jpg"/>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page