Imagick::getImageAlphaChannel
(PECL imagick 2 >= 2.3.0, PECL imagick 3)
Imagick::getImageAlphaChannel — 获取图像的 alpha 通道
说明
Imagick::getImageAlphaChannel(): int
获取图像的alpha通道值,为以下常量之一 alpha channel constants. 此方法在Imagick基于ImageMagick 6.4.0以上版本编译时可用。
返回值
返回当前图像的alpha通道值,该值是一个常量。该参考常量列表 alpha channel constants.
错误/异常
错误时抛出 ImagickException。

User Contributed Notes 1 note
phroggar ¶
4 months 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));
备份地址:http://www.lvesu.com/blog/php/imagick.getimagealphachannel.php