ConFoo: Call for paper is now Open

imagecropauto

(PHP 5 >= 5.5.0)

imagecropautoCrop an image automatically using one of the available modes

说明

resource imagecropauto ( resource $image [, int $mode = -1 [, float $threshold = .5 [, int $color = -1 ]]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

mode

One of IMG_CROP_* constants.

threshold

Used in IMG_CROP_THRESHOLD mode.

color

Used in IMG_CROP_THRESHOLD mode.

返回值

Return cropped image resource on success 或者在失败时返回 FALSE.

add a note add a note

User Contributed Notes 1 note

up
1
jordie at jordie dot org
1 month ago
Found the list of IMG_CROP_* constants in the PHP source code:

Essentially this function crops the image from any padded background if the background is a single standard colour. It will look at columns of pixels first, if a whole column is the same color that's being searched for, the column (image width) will be cropped. Then the pixel rows will be analyzed and height cropped.

IMG_CROP_TRANSPARENT - crops out a transparent background

IMG_CROP_BLACK - crops out a black background

IMG_CROP_WHITE - crops out a black background

IMG_CROP_SIDES - Uses the 4 corners of the image to attempt to detect the background to crop

IMG_CROP_THRESHOLD -  Crop an image using a given color. The threshold argument defines the tolerance 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.

IMG_CROP_DEFAULT - Attempts to use IMG_CROP_TRANSPARENT and if it fails it falls back to IMG_CROP_SIDES
To Top