PHP动态生成一种指定大小的随机图片的方法

本文介绍了一种PHP动态生成指定大小随机图片的方法,供大家参考:


< PHP
image_width = 100美元;
image_height = 100美元;
image_str美元=;
如果(isset($ _get {'w' }))
{
image_width = intval美元(美元_get {'w' });
}
如果(isset($ _get {错}))
{
image_height = intval美元(美元_get {错});
}
如果(isset($ _get {是}))
{
image_str美元=美元_get {是};
}
美元($ image_width img =画面欣赏,image_height美元);
颜色= imagecolorallocate美元(美元IMG,mt_rand(157255),mt_rand(157255),mt_rand(157255));
Imagefilledrectangle($ IMG,0,image_height美元,image_width美元,0美元,颜色);
(15, 30)mt_rand步=美元;
开始mt_rand美元=(0,$步);
颜色= imagecolorallocate美元(美元IMG,mt_rand(200255),mt_rand(200255),mt_rand(200255));
imagesetthickness($ IMG,mt_rand(3, 10));
如果($ image_height > image_width美元)
{
对(我=美元美元美元美元开始;我的<< image_height×2;$我+ = $步)
{
imageline(IMG 0美元美元,美元,我,我,0,美元的颜色);
}
}
其他的
{
对(我=美元美元美元美元开始;我的<< image_width×2;$我+ = $步)
{
imageline($ IMG,我0, 0美元,我美元,美元的颜色);
}
}
如果(image_str美元!=)
{
黑imagecolorallocate美元(美元IMG,0, 0, 0);
imagestring(IMG 12, 5, 5美元美元,美元,image_str,黑色);
}
头('content-type:图像/格式);
imagepng($ IMG);
销毁一图像($ IMG);




更多有关PHP相关内容的感兴趣的读者可以看到特别站:PHP图形和图片

希望本文能对PHP程序设计有所帮助。