略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Imagick::getImageAlphaChannel

2024-11-13

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。

add a noteadd a note

User Contributed Notes 1 note

up
1
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));

官方地址:https://www.php.net/manual/en/imagick.getimagealphachannel.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3