Crops a ColdFusion image to a specified rectangular area.

imageCrop(name, x, y, width, height) → returns void

Member Function Syntax

someImage.crop(x, y, width, height)

Argument Reference for the imageCrop function


Required: Yes
The image on which this operation is performed.


Required: Yes
The X origin of the crop area.


Required: Yes
The Y origin of the crop area.


Required: Yes
The width of the crop area.


Required: Yes
The height of the crop area.

Examples sample code invoking the imageCrop function

Tag Syntax

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

Using crop member function

CF 11+ Lucee 4.5+ Crop the image from starting point (x=25, y=25), with width=100 and height=100

imgObj = imageRead("");
cfimage(action="writeToBrowser", source=imgObj);

Fork me on GitHub