PHP動態產生指定大小隨機圖片的方法,_PHP教程

來源:互聯網
上載者:User

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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.