我正在尝试使用
PHP和GD创建一个图表.该图表已经有效,但我
无法使背景透明(具有抗锯齿功能).
我想在渐变背景上放置一个消除锯齿的线(这是HTML背景),但它显示了一些白色像素(请参阅下面的图像链接和我的代码).有可能用GD做到这一点吗?我在互联网上搜索了很多,但找不到任何解决方案.
PHP
$img = imagecreatetruecolor(1000, 1000);
imagesavealpha($img, true);
imagealphablending($img, true);
$color = imagecolorallocatealpha($img, 255, 255, 255, 127);
$red = imagecolorallocate($img, 255, 0, 0);
imagefill($img, 0, 0, $color);
imageantialias($img, true);
imageline($img, 10, 10, 500, 20, $red);
header("content-type: image/png");
imagepng($img);
imagedestroy($img);
?>
HTML
body{
background:url('/Image/background.png');
}