简体   繁体   English

PHP Imagick透明问题与PNG

[英]PHP Imagick transparency issue with PNG

I am using imagemagick 6.8.4-6 and i'm having an issue with setting the PNG on rotate to have a transparent background. 我正在使用imagemagick 6.8.4-6,并且在将PNG设置为旋转以具有透明背景时遇到问题。 My code is below and i am using imagick through php 我的代码在下面,我通过php使用imagick

$base = new Imagick("images/Champs-43.png"); 
$layer = new Imagick("images/coporate1.png");
$base->setFormat("png32");
$layer->setFormat("png32");
$layer->rotateImage(new ImagickPixel("none"), 45);

$base->compositeImage($layer, imagick::COMPOSITE_DEFAULT, 20, 20);
header('Content-Type: image/png');
echo $base;

the above gives a black background to the area rotated. 上面为旋转区域提供了黑色背景。 i have tried "none", "transparent", "#00000000", and "rgba(0, 0, 0, 0.0)" and none of them seem to work. 我已经尝试过“无”,“透明”,“#00000000”和“ rgba(0,0,0,0.0)”,但它们似乎都不起作用。

Any help appreciated 任何帮助表示赞赏

Try explicitly setting the ImagickPixel. 尝试显式设置ImagickPixel。

You can try these: 您可以尝试以下方法:

$layer->rotateImage(new ImagickPixel('#FFFFFF'), 45);

or 要么

$layer->rotateImage(new ImagickPixel('#00000000', 45);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM