PHP動態產生指定大小隨機圖片的方法,
本文執行個體講述了PHP動態產生指定大小隨機圖片的方法。分享給大家供大家參考,具體如下:
<?php$image_width = 100;$image_height = 100;$image_str = '';if (isset($_GET['w'])){ $image_width = intval($_GET['w']);}if (isset($_GET['h'])){ $image_height = intval($_GET['h']);}if (isset($_GET['s'])){ $image_str = $_GET['s'];}$img = imagecreate($image_width, $image_height);$color = imagecolorallocate($img, mt_rand(157,255), mt_rand(157,255), mt_rand(157,255));imagefilledrectangle($img, 0, $image_height, $image_width, 0, $color);$step = mt_rand(15, 30);$start = mt_rand(0, $step);$color = imagecolorallocate($img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255));imagesetthickness($img, mt_rand(3, 10));if ($image_height > $image_width){ for ($i=$start; $i<$image_height * 2; $i+=$step) { imageline($img, 0, $i, $i, 0, $color); }}else{ for ($i=$start; $i<$image_width * 2; $i+=$step) { imageline($img, $i, 0, 0, $i, $color); }}if ($image_str != ''){ $black = imagecolorallocate($img, 0, 0, 0); imagestring($img, 12, 5, 5, $image_str, $black);}header('Content-type:image/png');imagepng($img);imagedestroy($img);
更多關於PHP相關內容感興趣的讀者可查看本站專題:《PHP圖形與圖片操作技巧匯總》、《php操作office文檔技巧總結(包括word,excel,access,ppt)》、《php日期與時間用法總結》、《php物件導向程式設計入門教程》、《php字串(string)用法總結》、《php+mysql資料庫操作入門教程》及《php常見資料庫操作技巧匯總》
希望本文所述對大家PHP程式設計有所協助。
您可能感興趣的文章:
- php產生圖片驗證碼-附五種驗證碼
- 使用PHP產生圖片的縮圖的方法
- php產生圖片驗證碼的執行個體講解
- php使用Imagick產生圖片的方法
- php實現QQ空間擷取目前使用者的使用者名稱並產生圖片
- 用PHP代碼在網頁上產生圖片
- PHP批量產生圖片縮圖的方法
- php產生圖片驗證碼
- php產生圖片縮圖的方法
- 基於GD2圖形庫的PHP產生圖片縮圖類代碼分享
- phplot產生圖片類用法詳解
- PHP產生圖片驗證碼、點擊切換執行個體
- php將資料庫中的電話號碼讀取出來並產生圖片
http://www.bkjia.com/PHPjc/1113696.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1113696.htmlTechArticlePHP動態產生指定大小隨機圖片的方法, 本文執行個體講述了PHP動態產生指定大小隨機圖片的方法。分享給大家供大家參考,具體如下: php$ima...