Description

Specifies the degree of transparency of drawing functions.

Returns

Nothing.

Category

Image functions

Function syntax

ImageSetDrawingTransparency(name, percent)

See also

ImageSetAntialiasingImageSetBackgroundColorImageSetDrawingColorImageSetDrawingStrokeIsImageFile

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"/>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy