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

ImageCrop

Last update:
May 18, 2026

Description

Crops a ColdFusion image to a specified rectangular area.

Returns

Nothing.

Category

Function syntax

ImageCrop(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 origin of the crop area.
y
Required. The y origin of the crop area.
width
Required. The width of the crop area.
height
Required. The height of the crop area.

Usage

The rectangular area cannot be empty, and must be fully contained within the source image bounds.

Example

<!--- This example shows how to crop an image. ---> 
<!--- Create a ColdFusion image from an existing JPEG file. ---> 
<cfimage source="../cfdocs/images/artgallery/lori05.jpg" name="myImage"> 
<!--- Crop myImage to 100x100 pixels starting at the coordinates (10,10). 
---> 
<cfset ImageCrop(myImage,10,10,100,100)> 
<!--- Write the result to a file. ---> 
<cfimage source="#myImage#" action="write" destination="test_myImage.jpg" overwrite="yes"> 
<!--- Display the source image and the new image. ---> 
<img src="../cfdocs/images/artgallery/lori05.jpg"/> 
<img src="test_myImage.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