Crops a ColdFusion image to a specified rectangular area.
imageCrop(name, x, y, width, height)
→ returns void
someImage.crop(x, y, width, height)
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"/>
CF 11+ Lucee 4.5+ Crop the image from starting point (x=25, y=25), with width=100 and height=100
imgObj = imageRead("http://cfdocs.org/apple-touch-icon.png");
imgObj.crop(25,25,100,100);
cfimage(action="writeToBrowser", source=imgObj);
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.