我正在使用PHP旋转具有透明背景的PNG图像。但无论我尝试什么,原始图像周围仍然有一些黑线。
如何删除黑线。其他一切正常。图像是透明的,图像是旋转的,新的角也是透明的。只是原始正方形(旋转)周围的黑线让我很烦恼。
我使用此代码:
$angle = -100;
header('Content-type: image/png');
$image = 'http://mapning.com/img/plane.png';
$file = imagecreatefrompng($image);
$rotate = imagerotate($file, $angle, 0);
imageSaveAlpha($rotate, true);
ImageAlphaBlending($rotate, false);
$transparentColor = imagecolorallocatealpha($rotate, 200, 200, 200, 127);
imagefill($rotate, 0, 0, $transparentColor);
imagepng($rotate);
我在这里找到了答案:
http://ru2.php.net/manual/en/function.imagerotate.php#47985
我认为最好使用 imagick
这是 PHP 的扩展
或者,如果您想使用 GD,请参阅此处
http://ru2.php.net/manual/en/function.imagerotate.php#46338