我正在使用 PHP-GD。当我尝试使用 PHP 中的“imagecreatetruecolor”函数创建图像时,会生成图像。但这里的主要问题是由此生成的图像具有代码中指定的黑色背景,但其余部分整个页面也会变成灰色,并且无论 imagecreatetruecolor 函数中给出的属性如何,图像都会显示在窗口的中心。我已经在 PHP-GD 上工作了四个月,但从来没有发生过这种情况。但从上周开始,它的表现很尴尬。请帮我解决。
<?php
header("Content-type: image/png");
$img = imagecreatetruecolor(400, 400);
$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
$green = imagecolorallocate($img, 0, 255, 0);
$blue = imagecolorallocate($img, 0, 0, 255);
imagefilledellipse($img,100,100,10,10,$green);
imagefilledellipse($img,200,200,10,10,$green);
imagepng($img);
imagedestroy($img);
?>