Pankaj
Pankaj

Reputation: 10105

Issue while setting white color in blank image: php

Problem

Below code is creating an image with background color black.

I was expecting it to put white color. Am I missing anything in below code?

$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.

Upvotes: 0

Views: 114

Answers (1)

Syscall
Syscall

Reputation: 19780

The function imagefilledrectangle() use x1, y1 and x2, y2.

Try this :

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

or have a look to imagefill().

Upvotes: 1

Related Questions