[英]Why cant I make the background of a png transparent after rotating it with php?
昨天我整天都在尝试尝试解决这个问题。 我通过imagerotate()旋转图像。 我得到一个黑色背景,图像不再覆盖。 我已经尽力使该背景透明化..
这是我当前的代码。
function rotate($degrees) {
$image = $this->image;
imagealphablending($image, false);
$color = imagecolorallocatealpha($image, 0, 0, 0, 127);
$rotate = imagerotate($image, $degrees, $color);
imagecolortransparent($rotate, $color);
imagesavealpha($image, true);
$this->image = $rotate;
}
我真的开始被打勾。 有人可以给我看一些工作代码吗? 请?
我的WAMP服务器和Dreamweaver可能有问题吗? 因为我什至尝试过这个。.http ://www.exorithm.com/algorithm/view/rotate_image_alpha ,它仍然显示出黑色或白色背景。
尝试在旋转的图像上设置imagesavealpha()。
当前,您正在原始图像上运行imagesavealpha()。 [例如 imagesavealpha( $ image ,true); ]
相反,您想在旋转的图像上运行imagesavealpha(),然后设置$ this-> image ...尝试:
...
$rotate = imagerotate($image, $degrees, $color);
imagecolortransparent($rotate, $color);
imagesavealpha($rotate, true); // <- using $rotate instead of $image
$this->image = $rotate;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.