php影像處理

來源:互聯網
上載者:User

php影像處理 擷取圖片資源

resource imagecreatefromxxxx ( string $filename )
返回一映像標識符,代表了從給定的檔案名稱取得的映像。 擷取圖片相關資訊

getimagesize()

函數將測定任何 GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM 或 WBMP 影像檔的大小並返回映像的尺寸以及檔案類型和一個可以用於普通 HTML 檔案中 IMG 標記中的 height/width 文本字串。

array(7) {  [0] =>  int(60)  [1] =>  int(20)  [2] =>  int(2)  [3] =>  string(22) "width="60" height="20""  'bits' =>  int(8)  'channels' =>  int(3)  'mime' =>  string(10) "image/jpeg"}返回一個具有四個單元的數組。索引 0 包含映像寬度的像素值,索引 1 包含映像高度的像素值。索引 2 是映像類型的標記:1 = GIF,2 = JPG,3 = PNG,4 = SWF,5 = PSD,6 = BMP,7 = TIFF(intel byte order),8 = TIFF(motorola byte order),9 = JPC,10 = JP2,11 = JPX,12 = JB2,13 = SWC,14 = IFF,15 = WBMP,16 = XBM。這些標記與 PHP 4.3.0 新加的 IMAGETYPE 常量對應。索引 3 是文本字串,內容為“height="yyy" width="xxx"”,可直接用於 IMG 標記。
讀取某點的rgb

int imagecolorat ( resource image,int image , int x , int $y )
返回 image 所指定的圖形中指定位置像素的色彩索引值。
如果 PHP 編譯時間加上了 GD 庫 2.0 或更高的版本並且映像是真彩色映像,則本函數以整數返回該點的 RGB 值。用移位加掩碼來取得紅,綠,藍各自成分的值:

array imagecolorsforindex ( resource image,int image , int index )
本函數返回一個具有 red,green,blue 和 alpha 的鍵名的關聯陣列,包含了指定色彩索引的相應的值。

$im = imagecreatefrombmp($fileName);$rgb = imagecolorat($im, 100, 100);$r = ($rgb >> 16) & 0xFF;$g = ($rgb >> 8) & 0xFF;$b = $rgb & 0xFF;or imagecolorsforindex($im, $rgb);

聯繫我們

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