imagecropauto

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

imagecropautoRecorta una imagen automáticamente usando uno de los modos disponibles

Descripción

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

Advertencia

Esta función no está documentada actualmente, solamente se encuentra disponible la lista de parámetros.

Parámetros

image

Un recurso image, es devuelto por una de las funciones de creación de imágenes, como imagecreatetruecolor().

mode

Una de las constantes IMG_CROP_*.

threshold

Usado en modo IMG_CROP_THRESHOLD.

color

Usado en modo IMG_CROP_THRESHOLD.

Valores devueltos

Devuelve el recurso de la imagen recortada en caso de éxito o false en caso de error.

add a note add a note

User Contributed Notes 2 notes

up
4
raphael.deiana
7 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
0
Ray.Paseur sometimes uses Gmail
7 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