[英]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.