PHP畫圖的基本步驟GD庫

來源:互聯網
上載者:User

標籤:div   fill   data   建立   操作   bsp   back   str   php   

一:PHP建立一個圖片步驟:

1:建立畫布:

$im=imagecreatetruecolor(300,80)

 

2:定義顏色:

 

$black=imagecolorallocate($im, 0, 0, 0);

 

3:填充顏色|文字資訊:

 

imagefill($im, 0, 0, $black);

 

4:產生圖片:

 

imagepng($im,"./data/01.png")

 

5:銷毀圖片:

 

imagedestroy($im);

 

簡單案例:

 1 //1:建立一個畫圖資源(畫布) 2 $im=imagecreatetruecolor(300,80); 3  4 //2:建立顏色 5 $black=imagecolorallocate($im, 0, 0, 0); 6  7 //3:填充顏色(畫圖) 8 imagefill($im, 0, 0, $black); 9 10 11 //4:儲存圖片12 if(imagepng($im,"./data/01.png")){13     echo "圖片儲存成功";14 }else{15     echo "失敗";16 }17 18 //5:銷毀畫布,釋放資源19 imagedestroy($im);

 

 

二:引入一個圖片作為畫布

$image=imagecreatefromjpeg("./data/1.jpg");

後續操作一樣

提示:更多圖片操作及函數請到手冊查看GD

 

PHP畫圖的基本步驟GD庫

聯繫我們

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