PHP 8.3.4 Released!

Imagick::getImageAlphaChannel

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

Imagick::getImageAlphaChannelChecks if the image has an alpha channel

Açıklama

public Imagick::getImageAlphaChannel(): bool

Returns whether the image has an alpha channel.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

Returns true if the image has an alpha channel value and false if not, i.e. the image is RGB rather than RGBA or CMYK rather than CMYKA.

Hatalar/İstisnalar

Hata durumunda bir ImagickException istisnası oluşur.

Sürüm Bilgisi

Sürüm: Açıklama
imagick 3.6.0 Returns a bool now; previously, an int was returned.
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