用PHP创建白色图像 [英] create white image with php
本文介绍了用PHP创建白色图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用php创建空白图片,这是我的代码
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?
推荐答案
<?php
$img = imagecreatetruecolor(120, 20);
$bg = imagecolorallocate ( $img, 255, 255, 255 );
imagefilledrectangle($img,0,0,120,20,$bg);
imagejpeg($img,"myimg.jpg",100);
?>
这篇关于用PHP创建白色图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文