Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create white image with php

Tags:

php

gd

I trying create empty white image with php, this s my code

$bg = imagecreatetruecolor(120, 20);

imagejpeg($bg,"test/myimg.jpg",100);

but this created black image and I want create white, please tell how to set image for example white color?

like image 508
ოთო შავაძე Avatar asked Aug 11 '12 11:08

ოთო შავაძე


Video Answer


1 Answers

<?php
$img = imagecreatetruecolor(120, 20);
$bg = imagecolorallocate ( $img, 255, 255, 255 );
imagefilledrectangle($img,0,0,120,20,$bg);
imagejpeg($img,"myimg.jpg",100);
?>
like image 122
MilMike Avatar answered Sep 30 '22 13:09

MilMike