PHP影像處理

來源:互聯網
上載者:User

標籤:

1.建立畫布:

  $img=imagescreatetruecolor(200,200);

  建立顏色並填充

  $red=imagecolorallocate($img,255,0,0);  //建立顏色

  $imagefill($img,0,10,$red);  //填充顏色

2.畫圖形

  矩形:

    

    imagedrectangle($img,90,10,190,80,$green); 不填充的矩形
    imagefilledrectangle($img,90,10,190,80,$green); 填充的矩形

  線段:

    imageline($img,0,0,200,200,$blue);

  點:

    imagesetpixel ($img,50,50,$red);

  圓:

    imageellipse ($img,100,100,100,100,$green);

      image

      由圖象建立函數(例如imagecreatetruecolor())返回的圖象資源。

      cx

      中間的 X 座標。

      cy

      中間的 Y 座標。

      width

      橢圓的寬度。

      height

      橢圓的高度。

      color

      橢圓的顏色。顏色標識符由 imagecolorallocate() 建立。

  圓形:

    imagefilledarc($img,50,50,-160,40,$green);

    

 

  圓弧:

    imagefilledarc($img,50,50,100,50-160,40,$green,IMG_ARC_RIE);

      bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )
       imagefilledarc() 在 image 所代表的映像中以 cx,cy(映像左上方為 0, 0)畫一橢圓弧。如果成功則返回 TRUE,失敗則返回 FALSE。w 和 h 分別指定了橢圓的寬和高,s 和 e 參數以角度指定了起始和結束點。style 可以是下列值按位或(OR)後的值:

 

 

  寫字元到映像:

    水平畫:imagechar($img,5,100,100,"ABCDEFG",$red);

    垂直畫:imagecharup($img,5,100,100,"ABCDEFGHIJK",$red);

3.輸出資源

    header("Content-type:image/gif");

    imagegif($img);

4.釋放資源

    imagedestry($img);

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.