php圖形影像處理

來源:互聯網
上載者:User
  1. header("content-type:image/jpeg");
  2. /*一、簡單的映像輸出*/
  3. $im = imagecreate(60,40);
  4. $pink = imagecolorallocate($im,35, 25,220);
  5. imagejpeg($im);
  6. //imagestring($im,16, 200, 200,"I LOVE YOU",);
  7. /* 二、將字串寫入到圖片中 */
  8. //載入圖片
  9. $me=imagecreatefromjpeg("../../images/3.jpg");
  10. //設定字型顏色
  11. $text_color = imagecolorallocate($me, 255,84,0);
  12. //設定的字型的位置
  13. $font = "C:\Windows\Fonts\simkai.ttf";
  14. //要寫入的字串
  15. $str = iconv('GBK',"UTF-8", "php開發...");
  16. //將字串寫入到圖片中
  17. imagettftext($me,20,0,50,50, $text_color,$font, $str);
  18. //輸出圖片
  19. imagejpeg($me);
  20. //釋放資源
  21. imagedestroy($me);
複製代碼
  1. session_start();
  2. header("content-type:image/jpeg");
  3. //驗證碼
  4. //映像寬度
  5. $image_width =65;
  6. //映像高度
  7. $image_height =45;
  8. //設定隨機數的種子
  9. //srand(microtime()*1000);
  10. for ($i=0;$i<6;$i++){
  11. $new_str .=dechex(rand(0, 100));
  12. }
  13. $_SESSION[code]=$new_str;
  14. $image = imagecreate($image_width, $image_height);
  15. imagecolorallocate($image,rand(0,255), rand(0,255),rand(0,255));
  16. for ($i=0;$i $font = mt_rand(3, 8);//產生隨機字型大小
  17. $x = mt_rand(3,10)+$image_width*$i/4;
  18. $y = mt_rand(3,$image_height/4);
  19. $color = imagecolorallocate($image,mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
  20. imagestring($image, $font, $x, $y,$_SESSION[code][$i], $color);
  21. }
  22. imagepng($image);
  23. imagedestroy($image);
複製代碼
影像處理, php
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.