php圖片處理函數簡單例子

來源:互聯網
上載者:User
  1. //header('Content-Type:text/html;charset=utf-8');

  2. //影像處理
  3. //1 設定MIME類型 輸出類型 text/html 預設是網頁類型 可以不寫
  4. header('Content-Type:image/png;');
  5. $width = 400;
  6. $height = 400;
  7. //2 建立一個映像地區 寬度 高度
  8. $img = imagecreatetruecolor($width,$height);
  9. //為映像分配顏色 控制代碼 紅 綠 爛
  10. $blue = imagecolorallocate($img,0,102,255);
  11. //填充顏色 資源控制代碼 x軸 y軸 顏色
  12. imagefill($img,0,0,$blue);
  13. //繼續建立顏色
  14. $while = imagecolorallocate($img,255,255,255);
  15. //畫一個線條 控制代碼 x開始 y開始 x結束 y結束 顏色
  16. imageline($img,60,90,90,60,$while);
  17. //列印圖片資訊
  18. getimagesize($img);

  19. //繪製文本 控制代碼 字型大小 x軸 y軸 內容 顏色

  20. imagestring($img,5,0,0,'wwwww',$while);
  21. //載入圖片 list() 這個函數不錯
  22. imagecreatefrompng('22.png');
  23. //原圖從新採樣 拷貝到新圖上
  24. //新圖控制代碼 原圖控制代碼 新圖xy 原圖 xy 新圖長高 原圖長高
  25. imagecopyresampled($img,$yuan,40,40,0,0,$_width,$_height,$width,$height);
  26. //輸出圖片
  27. imagepng($img);
  28. //銷毀控制代碼
  29. imagedestroy($img);
  30. ?>

複製代碼
  • 聯繫我們

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