PHP 8.3.4 Released!

Imagick::getImageAlphaChannel

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

Imagick::getImageAlphaChannelVérifie si l'image a un canal alpha

Description

public Imagick::getImageAlphaChannel(): bool

Retourne si l'image a un canal alpha.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne true si l'image a une valeur de canal alpha et false sinon, c'est-à-dire que l'image est RGB plutôt que RGBA ou CMYK plutôt que CMYKA.

Erreurs / Exceptions

Lance une exception ImagickException si une erreur survient.

Historique

Version Description
imagick 3.6.0 Retourne un booléen maintenant ; auparavant, un entier était retourné.
add a note

User Contributed Notes 1 note

up
1
phroggar
2 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