Imagick::getImageAlphaChannel

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

Imagick::getImageAlphaChannelGets the image alpha channel

Descrierea

public Imagick::getImageAlphaChannel ( ) : int

Gets the image alpha channel value. The returned value is one of the alpha channel constants. Această metodă este disponibilă dacă Imagick a fost compilat cu ImageMagick de versiunea 6.4.0 sau ulterior.

Valorile întoarse

Returns a constant defining the current alpha channel value. Refer to this list of alpha channel constants.

Erori/Excepții

Emite ImagickException în caz de eroare.

add a note 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