Imagick::getImageAlphaChannel

(PECL imagick 2 >= 2.3.0, PECL imagick 3)

Imagick::getImageAlphaChannelVerifica si la imagen tiene un canal alfa

Descripción

public Imagick::getImageAlphaChannel(): bool

Devuelve si la imagen tiene un canal alfa.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve true si la imagen tiene un valor de canal alfa y false en caso contrario, es decir, que la imagen es RGB en lugar de RGBA o CMYK en lugar de CMYKA.

Errores/Excepciones

Lanza ImagickException en caso de error.

Historial de cambios

Versión Descripción
PECL imagick 3.6.0 Ahora devuelve un bool ; anteriormente se devolvía un int.
add a note

User Contributed Notes 1 note

up
0
phroggar
3 years ago
You want to check wether an image has an alpha channel? But you have no control which Imagick Version is used?

Background:

Method available since ImageMagick 6.4.0
Method returns boolean instead of int since 6.9.x

Example:

$image= new Imagick();
$image->readImage($source_file);

$imageHasAlphaChannel = (method_exists($image, 'getImageAlphaChannel') && ($document->getImageAlphaChannel() === \Imagick::ALPHACHANNEL_ACTIVATE || $document->getImageAlphaChannel() === true));
To Top