图像在尝试添加文本PHP时变得混乱



我正在尝试向预定义的图像添加文本,但未能这样做。我使用的代码如下:

<?php   
header("Content-type: image/png");
if(file_exists("stats_gen.png")){ unlink("stats_gen.png");} //delete old version
$string = "text";
$im     = imagecreatefrompng("stats.png");
$textcolor = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 5, 0, 0, $string, $textcolor);
imagepng($im); //show the image for debug purposes
imagepng($im, "stats_gen.png"); //save the image
imagedestroy($im);
?>

统计数据.png看起来像这样:哦,不支持图像格式。好吧,这个:http://lolmewn.nl/stats/stats.png,最终像 http://lolmewn.nl/stats/stats_gen.png 看起来很垃圾。我做错了什么?谷歌似乎没有给出任何答案...

使图像背景不透明。嘿。

最新更新