如何使用PHP Gmagik从PNG文件中提取alpha和其他通道


How to extract alpha and other channels from a PNG file with PHP Gmagick?

我正在尝试将2个图形magik命令移植到Gmagik php库(注意:而不是Imagick)。命令为:

  1. gm convert -matte -flatten image.png output.png
  2. gm convert -channel Matte -negate image.png output.png

基本上,我试图将透明png中的alpha通道提取到它自己的文件中,并将没有alpha的图像从php脚本中提取到另一个文件中。

我已经有了Imagick的等价物,但我对Gmagick感兴趣。

有人知道吗?

您可以使用Gmagik::separateeimagechannel来获取通道(获取蒙版通道的编号)。关于去除哑光通道,我没有任何线索,但这应该是可能的。