create white image with php

爷,独闯天下 提交于 2019-12-10 15:48:14

问题


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?


回答1:


<?php
$img = imagecreatetruecolor(120, 20);
$bg = imagecolorallocate ( $img, 255, 255, 255 );
imagefilledrectangle($img,0,0,120,20,$bg);
imagejpeg($img,"myimg.jpg",100);
?>


来源:https://stackoverflow.com/questions/11914301/create-white-image-with-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!