2017-03-13 45 views
0

我正在使用PHP-GD.When当我尝试在PHP中使用“imagecreatetruecolor”函数创建图像时,会生成图像。但是,这里产生的主要问题是如此生成的图像具有代码中指定的黑色背景,但整个页面的其余部分也变成灰色,并且图像显示在窗口的中心,而不管imagecreatetruecolor函数中给出的属性。自PHP-GD四个月以来一直工作,它从来没有发生过我。但形成上周它的行为尴尬。请帮我解决。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); 

?> 

This is the output when i try to execute the above code.As you see the image i created using php gd functions returns a image at the center of the window rather than attributes added to the function imagecreatetruecolor

回答

0

这是Chrome浏览器,而不是GD的结果。最新版本的Chrome将图像置于窗口中,并将窗口的其余部分设置为黑色背景。

如果你想看到这个动作,添加以下代码,让您的形象在白色背景:

imagefill($img, 0, 0, $white); 

,这将给你如下:

enter image description here

+0

广东话我们解决这个??我面临的问题是我不能理解图像大小,当我尝试保存图像时,它以php文件格式保存。 – Anvesh

+0

感谢您回答@niraj shah。它像以前一样在Internet Explorer中工作,您提供的有关Chrome的答案可以帮助我。 – Anvesh

相关问题