问题描述
我一直在尝试使用以下代码合并两个透明图像。基本图像是用作画布的完全透明图像。 我得到的结果如下图(第一张图片 - result.png)。如何让它完全透明?
function copyTransparent($src,$output,$srcWidth){
$x = 288;
$y = 85;
$bg = 'tranparent.png'; // fully transparent image as bg.
$margRight = abs(($x- $srcWidth)/2);
$img = imagecreatefrompng($bg);
imagealphablending($img,false);
imagesavealpha($img,true);
// copy from other
imagecopy($img,$src,$margRight,$x,$y);
// Save PNG
imagepng($img,9);
imagedestroy($img);
}
$png = 'testSign2.png';
list($width,$height) = getimagesize($png);
$src = imagecreatefrompng($png);
$newHeight = 85;
$ratio = $width / $height;
$newWidth = ceil($newHeight*$ratio);
$newImage = resizePng($src,$newWidth,$newHeight);
copyTransparent($newImage,"result.png",$newWidth);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)