我正在尝试使用PHP和GD创建图表。图表已经可以工作,但是我的 无法使背景透明(带有抗锯齿功能)。在PHP中使用透明背景与GD
我想在渐变背景(这是HTML背景)上放置一个抗锯齿线,但它显示了一些白色像素(请参阅下面的图像链接和我的代码)。 GD可以做到这一点吗?我在互联网上搜索了很多,但找不到任何解决方案。
PHP
<?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
<style type="text/css">
body{
background:url('/Image/background.png');
}
</style>
<img src="./example.php" />
我的经验是GD在抗锯齿方面很糟糕,你有没有考虑过使用ImageMagick? – 2012-04-03 15:30:32
不是真的(因为我的图表构建器几乎在GD中完成)。那里的反别名更好吗? – Marcel 2012-04-04 08:05:55