diff --git a/reference/image/functions/imagecropauto.xml b/reference/image/functions/imagecropauto.xml index 9e9b9b9770..91c8d49934 100644 --- a/reference/image/functions/imagecropauto.xml +++ b/reference/image/functions/imagecropauto.xml @@ -17,11 +17,9 @@ intcolor-1 - + Automatically crops an image according to the given + mode. - - &warn.undocumented.func; - @@ -32,15 +30,73 @@ mode - One of IMG_CROP_* constants. + One of the following constants: + + + IMG_CROP_DEFAULT + + + Attempts to use IMG_CROP_TRANSPARENT and if it + fails it falls back to IMG_CROP_SIDES. + + + + + IMG_CROP_TRANSPARENT + + + Crops out a transparent background. + + + + + IMG_CROP_BLACK + + + Crops out a black background. + + + + + IMG_CROP_WHITE + + + Crops out a white background. + + + + + IMG_CROP_SIDES + + + Uses the 4 corners of the image to attempt to detect the background to + crop. + + + + + IMG_CROP_THRESHOLD + + + Crops an image using the given threshold and + color. + + + + threshold - Used in IMG_CROP_THRESHOLD mode. + Specifies the tolerance in percent to be used while comparing the image + color and the color to crop. The method used to calculate the color + difference is based on the color distance in the RGB(a) cube. + + + Used only in IMG_CROP_THRESHOLD mode. @@ -48,7 +104,10 @@ color - Used in IMG_CROP_THRESHOLD mode. + Either an RGB color value or a palette index. + + + Used only in IMG_CROP_THRESHOLD mode. @@ -58,10 +117,39 @@ &reftitle.returnvalues; - Return cropped image resource on success&return.falseforfailure;. + Returns a cropped image resource on success&return.falseforfailure;. + If no cropping would occur, or the complete image would be cropped, that is + treated as failure, i.e. imagecrop returns &false;. + + &reftitle.examples; + + + Proper handling of auto-cropping + + As noted in the return value section, imagecropauto + returns &false; when there is either nothing to crop or the whole image + would be cropped. In this example we have an image resource + $im which should be automatically cropped only if there + is something to crop; otherwise we want to proceed with the original image. + + + +]]> + + + + +