imagecropauto

(PHP 5 >= 5.5.0, PHP 7)

imagecropautoCrop an image automatically using one of the available modes

Опис

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

Увага

This function is currently not documented; only its argument list is available.

Параметри

image

An image resource, returned by one of the image creation functions, such as 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 2 notes

up
4
raphael.deiana
5 years ago
In some cases the use of the IMG_CROP_WHITE or IMG_CROP_BLACK does not work. The function returns FALSE. It is best to use the IMG_CROP_THRESHOLD mode and specify the color in fourth argument as in the example below :

<?php

$original_img
= imagecreatefromjpeg($image_path);

// Use this :
$cropped_img_white = imagecropauto($original_img , IMG_CROP_THRESHOLD, null, 16777215);
// Rather than :
$cropped_img_white = imagecropauto($original_img , IMG_CROP_WHITE);

// AND

// Use this :
$cropped_img_black = imagecropauto($original_img , IMG_CROP_THRESHOLD, null, 0);
// Rather than :
$cropped_img_black = imagecropauto($original_img , IMG_CROP_BLACK);

?>
up
2
Ray.Paseur sometimes uses Gmail
5 years ago
Please see the note on ImageCrop() that describes an extraneous black line at the bottom of the cropped image.
http://php.net/manual/en/function.imagecrop.php#119537

Bug 67447 applies to ImageCropAuto(), too.
https://bugs.php.net/bug.php?id=67447
To Top