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

ImageClearRect

Last update:
May 18, 2026

Description

Clears the specified rectangle by filling it with the background color of the current drawing surface.

Returns

Nothing.

Category

Function syntax

ImageClearRect(name, x, y, width, height)

See also

History

ColdFusion 8: Added this function.

Parameters

Parameter
Description
name
Required. The ColdFusion image on which this operation is performed.
x
Required. The x coordinate of the rectangle to clear.
y
Required. The y coordinate of the rectangle to clear.
width
Required. The width of the rectangle to clear.
height
Required. The height of the rectangle to clear.

Usage

Use this function in conjunction with the ImageSetBackgroundColor function.

Example

<!--- This example shows how to set the background color to green and draws four rectangles in that color on the image. ---> 
<!--- Create a ColdFusion image from an existing JPEG file. ---> 
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage"> 
<!--- Set the background color to green. ---> 
<cfset ImageSetBackgroundColor(myImage,"green")> 
<!--- Draw four rectangles in the background color. ---> 
<cfset ImageClearRect(myImage,10,25,50,50)> 
<cfset ImageClearRect(myImage,100,25,50,50)> 
<cfset ImageClearRect(myImage,10,100,50,50)> 
<cfset ImageClearRect(myImage,100,100,50,50)> 
<!--- Save the modified ColdFusion image to a file. ---> 
<cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes"> 
<!--- Display the source image and the new image. ---> 
<img src="../cfdocs/images/artgallery/jeff05.jpg"/> 
<img src="test_myImage.jpeg"/>

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