發新話題

[分享] 《PHP》『圖形函式庫』

《PHP》『圖形函式庫』

《PHP》『圖形函式庫』GetImageSize --- 取得GIF、JPEG、PNG或SWF圖形的大小

GetImageSize

(PHP3 , PHP4)

GetImageSize ---  取得GIF、JPEG、PNG或SWF圖形的大小

語法 : array getimagesize (string filename [, array imageinfo])

說明 :

GetImageSize( )將會測定任何GIF、JPG、 PNG 或 SWF圖檔的大小,並且傳回圖檔的寬和高及檔案的類型,高和寬的字串會使用內部一個標準的HTML IMG標籤。

傳回的陣列有四個元素,索引值 0 表示圖形的寬為多少像素(pixels),索引值 1表示圖形的高,索引值 2則指出圖形為何種類型,1=GIF,2=JPG,3=PNG,索引值 3是個 "height=xxx width=xxx"的字串,它能直接的用在 IMG標籤中。

Example :

<?php

   <?php $size = GetImageSize ("img/flag.jpg"); ?>

   <IMG SRC="img/flag.jpg" <?php echo $size[3]; ?>

?>

非必需的參數imageinfo允許你從圖檔中取出一些延伸的資訊,現在這將會傳回不同的JPG APP標識(markers)在組合的陣列中,有些程式會使用到這些APP標識來將文字資訊植入圖形中,一個相當常見的植入IPTC 訪客無法瀏覽此圖片或連結,請先 註冊登入會員 資訊在APP13標識中。你可以使用iptcparse( )函式來剖析二進制APP13標識,成為可讀的。

Example :

<?php

    $size = GetImageSize ("testimg.jpg",&$info);

    if (isset ($info["APP13"])) {

            $iptc = iptcparse ($info["APP13"]); var_dump ($iptc);

    }

?>

注意 : 此函式並不需要GD圖形函式庫



[ 本帖最後由 蔡逸竹 於 2006-9-25 04:46 編輯 ]

TOP

《PHP》『圖形函式庫』ImageArc --- 畫弧線

ImageArc

(PHP3 , PHP4)

ImageArc ---  畫弧線

語法 : int imagearc (int im, int cx, int cy, int w, int h, int s, int e, int col)

說明 :

ImageArc( )在im所代表的圖形中,以參數 cx,cy(左上方是 0,0)為圓心畫一弧形,參數 w和 h分別表示弧形的寬和高,參數 s和 e則指出弧形的起始角和結束角的度數。

TOP

《PHP》『圖形函式庫』ImageChar --- 畫一個水平的字元

ImageChar

(PHP3 , PHP4)

ImageChar ---  畫一個水平的字元

語法 : int imagechar (int im, int font, int x, int y, string c, int col)

說明 :

ImageChar( )在圖形 im上,位置在 x,y的地方(左上方是 0,0),顏色為 col,畫出 c的第一個字元,如果字體 font是1、2、3、4或 5,則使用嵌入的字體(數值愈大字體也愈大)

參考 : imageloadfont( )

TOP

《PHP》『圖形函式庫』ImageCharUp --- 畫一個垂直的字元

ImageCharUp

(PHP3 , PHP4)

ImageCharUp ---  畫一個垂直的字元

語法 : int imagecharup (int im, int font, int x, int y, string c, int col)

說明 :

ImageChar( )在圖形 im上,位置在 x,y的地方(左上方是 0,0),顏色為 col,畫出垂直的 c的第一個字元,如果字體 font是1、2、3、4或 5,則使用嵌入的字體(數值愈大字體也愈大)

參考 : imageloadfont( )

TOP

《PHP》『圖形函式庫』ImageColorAllocate --- 分配圖形的顏色

ImageColorAllocate

(PHP3 , PHP4)

ImageColorAllocate ---  分配圖形的顏色

語法 : int imagecolorallocate (int im, int red, int green, int blue)

說明 :

ImageColorAllocate( )傳回一個顏色的 identifier,表示顏色是由給予的RGB成份所組成的,參數 im是由imagecreate( )傳回的,要用在圖形 im中的顏色,必須呼叫ImageColorAllocate( )來建立各種顏色。

Example :

<?php

    $white = ImageColorAllocate ($im, 255, 255, 255);

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

?>

TOP

《PHP》『圖形函式庫』ImageColorDeAllocate --- 減少一個分配給圖形的顏色

ImageColorDeAllocate

(PHP3 >= 3.0.6 , PHP4)

ImageColorDeAllocate ---  減少一個分配給圖形的顏色

語法 : int imagecolordeallocate (int im, int index)

說明 :

ImageColorDeAllocate( )減少一個先前ImageColorAllocate分配給圖形的顏色。

Example :

<?php

   $white = ImageColorAllocate($im, 255, 255, 255);

   ImageColorDeAllocate($im, $white);

?>

TOP

《PHP》『圖形函式庫』ImageColorAt --- 取得像素的顏色索引值

ImageColorAt

(PHP3 , PHP4)

ImageColorAt ---  取得像素的顏色索引值

語法 : int imagecolorat (int im, int x, int y)

說明 :

傳回圖形中指定位置的像素的顏色索引值。

參考 : imagecolorset( )  imagecolorsforindex( )

TOP

《PHP》『圖形函式庫』ImageColorClosest --- 取得最接近指定的顏色的索引值

ImageColorClosest

(PHP3 , PHP4)

ImageColorClosest ---  取得最接近指定的顏色的索引值

語法 : int imagecolorclosest (int im, int red, int green, int blue)

說明 :

傳回圖形的調色盤中,最接近指定的RGB值的顏色索引值。

參考 : imagecolorexact( )

TOP

《PHP》『圖形函式庫』ImageColorExact --- 取得指定的顏色的索引值

ImageColorExact

(PHP3 , PHP4)

ImageColorExact ---  取得指定的顏色的索引值

語法 : int imagecolorexact (int im, int red, int green, int blue)

說明 :

傳回圖形的調色盤中,指定的顏色的索引值。

如果顏色不在圖形的調色盤上,則傳回-1。

參考 : imagecolorclosest( )

TOP

《PHP》『圖形函式庫』ImageColorResolve --- 取得指定的或最接近的顏色的索引值

ImageColorResolve

(PHP3 >= 3.0.2 , PHP4)

ImageColorResolve ---  取得指定的或最接近的顏色的索引值

語法 : int imagecolorresolve (int im, int red, int green, int blue)

說明 :

此函式肯定會傳回一個請求的顏色索引值,會傳回指定的或是接近的顏色的索引值。

參考 : imagecolorclosest( )

TOP

發新話題

本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。