在空白图像中设置白色时出现问题:php

时间:2018-01-27 12:12:50

标签: php

问题

下面的代码是创建一个背景颜色为黑色的图像。

我期待它变成白色。我在下面的代码中遗漏了什么吗?

$img = imagecreatetruecolor(600, 1000);
$bg = imagecolorallocate ( $img, 255, 255, 255 );
imagefilledrectangle($img, 0, 0, 0, 0, $bg);
imagejpeg($img, "myimg.jpg", 100);

I am following this accepted answer.

1 个答案:

答案 0 :(得分:1)

函数imagefilledrectangle()使用x1,y1和 x2,y2

试试这个:

imagefilledrectangle($img, 0, 0, 600, 1000, $bg);

或查看imagefill()