ImageCFC: Documentation: Method Description

imageCFC.crop()

Description

crops an image.

Returns

A structure containing the following fields:

keyvalue
errorCode0 for success, non-zero for failure. Always returned, but not really used if the throwOnError option is set to true.
errorMessageA description of the error. Always returned, but not really used if the throwOnError option is set to true.
imgA java BufferedImage object is returned if no output file is specified

Function Syntax

crop(objImage,inputFile,outputFile,startX,startY,newWidth,newHeight,jpegCompression)

ParameterRequired?DefaultDescription
objImage YES - A java image object, or a blank string.
inputFile YES - File path or URL to an image, or a blank string.
outputFile YES - File path to write the output, or a blank string.
fromX YES - X coordinate of the upper left corner of the cropped image.
fromY YES - Y coordinate of the upper left corner of the cropped image.
newWidth YES - Width in pixels of the resulting image.
newHeight YES - Height in pixels of the resulting image.
jpegCompression NO defaultJpegCompression jpeg compression quality to use if writing a jpeg file. 0-100. 100 is the highest quality.

You must supply either an image object or a file path to a source image.

Example

<cfset imageCFC = createObject("component","image")>
<cfset imgInfo = imageCFC.crop("", "C:\Inetpub\wwwroot\myimage.jpg", "C:\Inetpub\wwwroot\myimage2.jpg",1,1,100,200)>
<img src="myimage2.jpg" width="100" height="200" alt="cropped image to 100x200 starting at the upper left corner."/>


Please read this project's LICENSE

This is an open source project written by Rick Root. Please visit The Coldfusion Open Source Blog for more information.

Please report bugs, make suggestions, and send compliments to me via email.