PHP |想象一下 getImageAlphaChannel()函数
Imagick::getImageAphaChannel()函数是PHP中的一个内置函数,用于获取图像 alpha 通道。返回值是 ALPHACHANNEL 常量之一。
句法:
int Imagick::getImageAlphaChannel( void )
参数:此函数不接受任何参数。
异常:此函数在出错时抛出 ImagickException。
返回值:此函数在成功时返回一个整数值。
ALPHACHANNEL 常量列表如下:
- imagick::ALPHACHANNEL_ACTIVATE (0)
- 想像::ALPHACHANNEL_DEACTIVATE (1)
- imagick::ALPHACHANNEL_RESET (2)
- 想像::ALPHACHANNEL_SET (3)
- imagick::ALPHACHANNEL_UNDEFINED (4)
- imagick::ALPHACHANNEL_COPY (5)
- 想像::ALPHACHANNEL_EXTRACT (6)
- imagick::ALPHACHANNEL_OPAQUE (7)
- 想像::ALPHACHANNEL_SHAPE (8)
- imagick::ALPHACHANNEL_TRANSPARENT (9)
下面的程序说明了PHP中的Imagick::getImageAlphaChannel()函数:
方案一:
getImageAlphaChannel();
echo $alphaChannel;
?>
输出:
1 ( which corresponds to imagick::ALPHACHANNEL_DEACTIVATE. )
方案二:
getImageAlphaChannel();
echo $alphaChannel . "
";
// Set the alpha channel
$alphaChannel = $imagick->setImageAlphaChannel(imagick::ALPHACHANNEL_RESET );
// Get the Alpha Channel
$alphaChannel = $imagick->getImageAlphaChannel();
echo $alphaChannel;
?>
输出:
0
1
参考: https://www. PHP.net/manual/en/imagick.getimagealphachannel。 PHP