php-GD庫的函數使用

jopen 10年前發布 | 34K 次閱讀 php-GD PHP開發

    <?php
//getimagesize - 取得圖片的大小[即長與寬]
//print_r(getimagesize("./logo_i.gif"));
//Array ( [0] => 240 [1] => 124 [2] => 1 [3] => width="240" height="124" [bits] => 8 [channels] => 3 [mime] => image/gif )

    //image_type_to_mime_type - 取得 getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的圖像類型的 MIME 類型  
    //$aa = getimagesize("./logo_i.gif");  
    //print_r(image_type_to_mime_type ($aa));  

    //imagearc — 畫橢圓弧  
    /*bool imagearc(resource $image ,int $cx ,int $cy ,int $w ,int $h , int $s , int $e , int $color); 
    //$image:資源 
    //$cx:左邊離圓心的位置 
    //$cy:上邊離圓心的位置 
    //$w:圓形的直徑左右 
    //$h:圓形的直徑上下 
    //$s:0度順時針畫 
    //$e:360 
    //$color:圓形的顏色 
    // 創建一個 200X200 的圖像 
    $img = imagecreatetruecolor(200, 200); 
    // 分配顏色 
    $white = imagecolorallocate($img, 255, 255, 255); 
    $black = imagecolorallocate($img, 0, 0, 0); 
    // 畫一個白色的圓 
    imagearc($img, 100, 100, 150, 150, 0, 360, $white); 
    // 將圖像輸出到瀏覽器 
    header("Content-type: image/png"); 
    imagepng($img); 
    // 釋放內存 
    imagedestroy($img);*/  

    //imagechar — 水平地畫一個字符  
    /*bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color ) 
    $image:資源 
    $font:字體大小 
    $x:文字離左邊框的距離 
    $y:文字離上邊框的距離 
    $c:將字符串 c 的第一個字符畫在 image 指定的圖像中 
    $color:文字的顏色 
    $im = imagecreate(100,100); 
    $string = 'php'; 
    $bg = imagecolorallocate($im, 255, 255, 255); 
    $black = imagecolorallocate($im, 0, 0, 0); 
    // prints a black "P" in the top left corner 
    imagechar($im, 1, 0, 0, $string, $black); 
    header('Content-type: image/png'); 
    imagepng($im);*/  

    //imagecharup — 垂直地畫一個字符  
    /*bool imagecharup ( resource $image , int $font , int $x , int $y , string $c , int $color ) 
    $image:資源 
    $font:字體大小 
    $x:文字離左邊框的距離 
    $y:文字離上邊框的距離 
    $c:將字符串 c 的第一個字符畫在 image 指定的圖像中 
    $color:文字的顏色 
    $im = imagecreate(100,100); 
    $string = 'Note that the first letter is a N'; 
    $bg = imagecolorallocate($im, 255, 255, 255); 
    $black = imagecolorallocate($im, 0, 0, 0); 
    // prints a black "Z" on a white background 
    imagecharup($im, 3, 10, 10, $string, $black); 
    header('Content-type: image/png'); 
    imagepng($im); 
    */  

    //imagecolorallocate — 為一幅圖像分配顏色  
    /*int imagecolorallocate ( resource $image , int $red , int $green , int $blue ) 
    $image:圖片資源 
    $red,$green,$blue分別是所需要的顏色的紅,綠,藍成分。這些參數是 0 到 255 的整數或者十六進制的 0x00 到 0xFF 
    第一次對 imagecolorallocate() 的調用會給基于調色板的圖像填充背景色 
    $im = imagecreate( 100, 100); 
    // 背景設為紅色 
    $background = imagecolorallocate($im, 255, 0, 0); 
    // 設定一些顏色 
    $white = imagecolorallocate($im, 255, 255, 255); 
    $black = imagecolorallocate($im, 0, 0, 0); 
    // 十六進制方式 
    $white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); 
    $black = imagecolorallocate($im, 0x00, 0x00, 0x00); 
    header('Content-type: image/png'); 
    imagepng($im); 
    */  

    //imagecolorallocatealpha — 為一幅圖像分配顏色 + alpha  
    /*int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha ) 
    imagecolorallocatealpha() 的行為和 imagecolorallocate() 相同,但多了一個額外的透明度參數 alpha,其值從 0 到 127。0 表示完全不透明,127 表示完全透明。 
    $size = 300; 
    $image=imagecreatetruecolor($size, $size); 
    // 用白色背景加黑色邊框畫個方框 
    $back = imagecolorallocate($image, 255, 255, 255); 
    $border = imagecolorallocate($image, 0, 0, 0); 
    imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back); 
    imagerectangle($image, 0, 0, $size - 1, $size - 1, $border); 
    $yellow_x = 100; 
    $yellow_y = 75; 
    $red_x    = 120; 
    $red_y    = 165; 
    $blue_x   = 187; 
    $blue_y   = 125; 
    $radius   = 150; 
    // 用 alpha 值分配一些顏色 
    $yellow = imagecolorallocatealpha($image, 255, 255, 0, 75); 
    $red    = imagecolorallocatealpha($image, 255, 0, 0, 75); 
    $blue   = imagecolorallocatealpha($image, 0, 0, 255, 75); 
    // 畫三個交迭的圓 
    imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow); 
    imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red); 
    imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue); 
    // 不要忘記輸出正確的 header! 
    header('Content-type: image/png'); 
    // 最后輸出結果 
    imagepng($image); 
    imagedestroy($image); 
    */  

    //imagecolordeallocate — 取消圖像顏色的分配  
    /*bool imagecolordeallocate ( resource $image , int $color ) 
    imagecolordeallocate() 函數取消先前由 imagecolorallocate() 或 imagecolorallocatealpha() 分配的顏色。  
    $im = imagecreate( 100, 100); 
    // 背景設為紅色 
    $background = imagecolorallocate($im, 255, 0, 0); 
    // 設定一些顏色 
    $white = imagecolorallocate($im, 255, 255, 255); 
    imagecolordeallocate($im,$white); 
    header('Content-type: image/png'); 
    imagepng($im);*/  

    //imagecolorexact — 取得指定顏色的索引值  
    /*int imagecolorexact ( resource $image , int $red , int $green , int $blue ) 
    返回圖像調色板中指定顏色的索引值。  
    如果顏色不在圖像的調色板中,返回 -1。  
    如果從文件創建了圖像,只有圖像中使用了的顏色會被辨析。僅出現在調色板中的顏色不會被辨析。 
    $im = imagecreate( 100, 100); 
    // 背景設為紅色 
    $background = imagecolorallocate($im, 255, 0, 0); 
    // 設定一些顏色 
    $white = imagecolorallocate($im, 255, 255, 255); 
    $aa = imagecolorexact ($im, 255, 0, 0); 
    echo $aa;   //不存在返回-1*/  

    //imagecolorset — 給指定調色板索引設定顏色  
    /*void imagecolorset ( resource $image , int $index , int $red , int $green , int $blue ) 
    本函數將調色板中指定的索引設定為指定的顏色。 
    $im = imagecreate( 100, 100); 
    $background = imagecolorallocate($im, 255, 0, 0); 
    for($c = 0;$c<50;$c++){ 
        imagecolorset($im,$c,255,255,255 ); 
    } 
    header('Content-type: image/png'); 
    imagepng($im);*/  

    //imagecolortransparent — 將某個顏色定義為透明色  
    /*int imagecolortransparent ( resource $image [, int $color ] ) 
    imagecolortransparent() 將 image 圖像中的透明色設定為 color。image 是 imagecreatetruecolor() 返回的圖像標識符,color 是 imagecolorallocate() 返回的顏色標識符。  
    $im = imagecreate(100,100); 
    $background = imagecolorallocate($im, 0, 0, 0); 
    imagecolortransparent ($im,$background); 
    header('Content-type: image/png'); 
    imagepng($im);*/  

?>  </pre><pre class="brush:php; toolbar: true; auto-links: false;">    <?php   
    //imagecopy — 拷貝圖像的一部分粘貼到某圖像上  
    /*bool imagecopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) 
    $dst_im:被粘貼的圖片 
    $src_im:復制圖片的一部分的圖片 
    $dst_x:粘貼到圖片上的圖片離左邊的距離 
    $dst_y:粘貼到圖片上的圖片離上邊的距離 
    $src_x:復制圖片時離左邊多大距離開始復制 
    $src_y:復制圖片時離上邊多大距離開始復制 
    $src_w:復制圖片的寬 
    $src_h:復制圖片的長 
    $im = imagecreate(100,100); 
    $image = imagecreatefromjpeg('1.jpg');  
    imagecolorallocate($im, 255, 0, 0); 
    imagecopy($im,$image,10,10,100,100,100,100); 
    header('Content-type: image/png'); 
    imagepng($im);*/  

    //imagecopymerge — 拷貝并合并圖像的一部分(也就是傳說中的圖片屬性)  
    /*bool imagecopymerge ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct ) 
    $dst_im:被粘貼的圖片 
    $src_im:復制圖片的一部分的圖片 
    $dst_x:粘貼到圖片上的圖片離左邊的距離 
    $dst_y:粘貼到圖片上的圖片離上邊的距離 
    $src_x:復制圖片時離左邊多大距離開始復制 
    $src_y:復制圖片時離上邊多大距離開始復制 
    $src_w:復制圖片的寬 
    $src_h:復制圖片的長 
    $pct:透明度0-100數字越小越透明,當為0時就完全看不見了 
    $im = imagecreatefromjpeg('1.jpg');  
    $image = imagecreatefrompng('code.png'); 
    imagecopymerge ($im,$image,10,10,0,0,100,100,10); 
    header('Content-type: image/png'); 
    imagejpeg($im); 
    */  

    //imagecopymergegray — 用灰度拷貝并合并圖像的一部分  
    /*bool imagecopymergegray ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct ) 
    $dst_im:被粘貼的圖片 
    $src_im:復制圖片的一部分的圖片 
    $dst_x:粘貼到圖片上的圖片離左邊的距離 
    $dst_y:粘貼到圖片上的圖片離上邊的距離 
    $src_x:復制圖片時離左邊多大距離開始復制 
    $src_y:復制圖片時離上邊多大距離開始復制 
    $src_w:復制圖片的寬 
    $src_h:復制圖片的長 
    $pct:灰透明0-100數字越小越透明,當為0時就是一個灰色圖片 
    $im = imagecreatefromjpeg('1.jpg');  
    $image = imagecreatefrompng('code.png'); 
    imagecopymergegray  ($im,$image,10,10,0,0,100,100,0); 
    header('Content-type: image/png'); 
    imagejpeg($im); 
    */  

    //imagecopyresampled — 重采樣拷貝部分圖像并調整大小  
    /*bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) 
    $dst_im:被粘貼的圖片 
    $src_im:復制圖片的一部分的圖片 
    $dst_x:粘貼到圖片上的圖片離左邊的距離 
    $dst_y:粘貼到圖片上的圖片離上邊的距離 
    $src_x:復制圖片時離左邊多大距離開始復制 
    $src_y:復制圖片時離上邊多大距離開始復制 
    $dst_w:被粘貼的圖片給留的寬度 
    $dst_h:被粘貼的圖片給留的寬度 
    $src_w:復制圖片的寬 
    $src_h:復制圖片的長 
    $im = imagecreatefromjpeg('1.jpg');  
    $image = imagecreatefrompng('code.png'); 
    imagecopyresampled ($im,$image,0,0,0,0,100,100,100,100); 
    header('Content-type: image/png'); 
    imagejpeg($im); */  

    //imagecopyresized — 拷貝部分圖像并調整大小  
    /*bool imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) 
    $dst_im:被粘貼的圖片 
    $src_im:復制圖片的一部分的圖片 
    $dst_x:粘貼到圖片上的圖片離左邊的距離 
    $dst_y:粘貼到圖片上的圖片離上邊的距離 
    $src_x:復制圖片時離左邊多大距離開始復制 
    $src_y:復制圖片時離上邊多大距離開始復制 
    $dst_w:被粘貼的圖片給留的寬度 
    $dst_h:被粘貼的圖片給留的寬度 
    $src_w:復制圖片的寬 
    $src_h:復制圖片的長 
    $im = imagecreatefromjpeg('1.jpg');  
    $image = imagecreatefrompng('code.png'); 
    imagecopyresized  ($im,$image,0,0,0,0,100,100,100,100); 
    header('Content-type: image/png'); 
    imagejpeg($im);*/  

    //imagecreate — 新建一個基于調色板的圖  
    /*resource imagecreate ( int $x_size , int $y_size ) 
    $x_size:圖片的寬 
    $y_size:圖片的長 
    $im = imagecreate(100,50); 
    header('Content-type: image/png'); 
    imagejpeg($im); 
    */  

    //imagecreatefromgd2 — 從 GD2 文件或 URL 新建一圖像  
    //imagecreatefromgd2part — 從給定的 GD2 文件或 URL 中的部分新建一圖像  
    //imagecreatefromgd — 從 GD 文件或 URL 新建一圖像  
    //imagecreatefromgif — 從 GIF 文件或 URL 新建一圖像  
    //imagecreatefromjpeg — 從 JPEG 文件或 URL 新建一圖像  
    //imagecreatefrompng — 從 PNG 文件或 URL 新建一圖像  
    //imagecreatefromstring — 從字符串中的圖像流新建一圖像  
    //imagecreatefromwbmp — 從 WBMP 文件或 URL 新建一圖像  
    //imagecreatefromxbm — 從 XBM 文件或 URL 新建一圖像  
    //imagecreatefromxpm — 從 XPM 文件或 URL 新建一圖像  
    /*以上都是根據不同類型獲取文件新建一個圖像*/  

    //imagecreatetruecolor — 新建一個真彩色圖像  
    /*resource imagecreatetruecolor ( int $x_size , int $y_size ) 
    imagecreatetruecolor() 返回一個圖像標識符,代表了一幅大小為 x_size 和 y_size 的黑色圖像。  
    $im = imagecreatetruecolor(100,100); 
    header('Content-type: image/png'); 
    imagejpeg($im); 
    */  

    //imagedestroy — 銷毀一圖像  
    /*bool imagedestroy ( resource $image ) 
    $im = imagetcreate(100,100); 
    imagedestroy($im); 
    */  

    //imageellipse — 畫一個橢圓  
    /*bool imageellipse ( resource $image , int $cx , int $cy , int $w , int $h , int $color ) 
    $image:資源 
    $cx:左邊離圓心的位置 
    $cy:上邊離圓心的位置 
    $w:圓形的直徑左右 
    $h:圓形的直徑上下 
    $color:線的顏色 
    $image = imagecreatetruecolor(400, 400); 
    // 選擇橢圓的顏色 
    $col_ellipse = imagecolorallocate($image, 255, 255, 0); 
    // 畫一個橢圓 
    imageellipse($image, 200, 200, 350, 350, $col_ellipse); 
    // 輸出圖像 
    header("Content-type: image/png"); 
    imagepng($image); 
    */  

    //imagefill — 區域填充  
    /*bool imagefill ( resource $image , int $x , int $y , int $color ) 
    imagefill() 在 image 圖像的坐標 x,y(圖像左上角為 0, 0)處用 color 顏色執行區域填充(即與 x, y 點顏色相同且相鄰的點都會被填充)。  
    $im = imagecreatetruecolor(100, 100); 
    // 將背景設為紅色 
    $red = imagecolorallocate($im, 255, 0, 0); 
    imagefill($im, 50, 50, $red); 
    header('Content-type: image/png'); 
    imagepng($im); 
    imagedestroy($im); 
    */  

    //imagefilledarc — 畫一橢圓弧且填充  
    /*bool imagefilledarc ( resource $image , int $cx , int $cy , int $w , int $h , int $s , int $e , int $color , int $style ) 
    $image:資源 
    $cx:左邊離圓心的位置 
    $cy:上邊離圓心的位置 
    $w:圓形的直徑左右 
    $h:圓形的直徑上下 
    $s:0度順時針畫 
    $e:360 
    $color:填充的顏色 
    $style:類型以下是4中類型 
    IMG_ARC_PIE 和 IMG_ARC_CHORD 是互斥的; 
    IMG_ARC_CHORD 只是用直線連接了起始和結束點, 
    IMG_ARC_PIE 則產生圓形邊界(如果兩個都用,IMG_ARC_CHORD 生效)。 
    IMG_ARC_NOFILL 指明弧或弦只有輪廓,不填充。 
    IMG_ARC_EDGED 指明用直線將起始和結束點與中心點相連, 
    和 IMG_ARC_NOFILL 一起使用是畫餅狀圖輪廓的好方法(而不用填充)。  
    $im = imagecreatetruecolor(200,200); 
    $red = imagecolorallocate($im, 255, 255, 0); 
    imagefilledarc ($im,100,100,150,150,0,360,$red,IMG_ARC_PIE); 
    header('Content-type: image/png'); 
    imagepng($im); 
    imagedestroy($im); 
    */  
?>  </pre><pre class="brush:php; toolbar: true; auto-links: false;">    <?php  
    //imagefilledellipse — 畫一橢圓并填充  
    /*bool imagefilledellipse ( resource $image , int $cx , int $cy , int $w , int $h , int $color ) 
    $image:圖片資源 
    $cx:左邊離圓心的位置 
    $cy:上邊離圓心的位置 
    $w:圓形的直徑(左右方向) 
    $h:圓形的直徑(上下方向) 
    $color:填充的顏色 
    $im = imagecreatetruecolor(100,100); 
    $red = imagecolorallocate($im,0,255,0); 
    imagefilledellipse($im,50,50,80,80,$red); 
    header('Content-type: image/png'); 
    imagepng($im); 
    */  

    //imagefilledpolygon — 畫一多邊形并填充  
    /*bool imagefilledpolygon ( resource $image , array $points , int $num_points , int $color ) 
    $image:圖片資源 
    $points:參數是一個按順序包含有多邊形各頂點的 x 和 y 坐標的數組 
    $num_points:參數是頂點的總數,必須大于 3 
    $color:顏色 
    $im = imagecreatetruecolor(200,200); 
    $value = array( 25,40,36,53,87,12,45,98,56,23); 
    $red = imagecolorallocate($im,255,0,0); 
    imagefilledpolygon($im,$value,5,$red); 
    header('Content-type: image/png'); 
    imagepng($im); 
    */  

    //imagefilledrectangle — 畫一矩形并填充  
    /*bool imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) 
    $image:圖片資源 
    $x1:點到左邊的距離 
    $y1:點到上邊的距離 
    $x2:點到左邊的距離 
    $y2:點到上邊的距離 
    $color:填充的顏色 
    $im = imagecreatetruecolor(200,200); 
    $red = imagecolorallocate($im,255,0,0); 
    imagefilledrectangle($im,10,10,190,190,$red); 
    header('Content-type:image/png'); 
    imagepng($im); 
    */  

    //imagefontheight — 取得字體高度  
    /*$font_size = 1; 
    $a = imagefontheight($font_size); 
    echo $a; 
    */  

    //imagefontwidth — 取得字體寬度  
    /*$font_size = 1; 
    $b = imagefontwidth($font_size); 
    echo $b; 
    */  

    //imageline — 畫一條線段  
    /*bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) 
    $image:圖片資源 
    $x1:點到左邊的距離 
    $y1:點到上邊的距離 
    $x2:點到左邊的距離 
    $y2:點到上邊的距離 
    $color:線段的顏色 
    $im = imagecreatetruecolor(200,200); 
    $red = imagecolorallocate($im,255,0,0); 
    imageline($im,10,10,100,100,$red); 
    header('Content-type:image/png'); 
    imagepng($im); 
    */  

    //imagepolygon — 畫一個多邊形  
    /*bool imagepolygon ( resource $image , array $points , int $num_points , int $color ) 
    $image:圖片資源 
    $points:參數是一個按順序包含有多邊形各頂點的 x 和 y 坐標的數組 
    $num_points:是頂點的總數。大于3 
    $color:線段的顏色 
    $im = imagecreatetruecolor(200,200); 
    $red = imagecolorallocate($im,255,0,0); 
    $value = array(13,45,23,56,23,45,78,99); 
    imagepolygon($im,$value,4,$red); 
    header('Content-type:image/png'); 
    imagepng($im); 
    */  

    //imagerectangle — 畫一個矩形  
    /*bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col ) 
    $image:圖片資源 
    $x1:點到左邊的距離 
    $y1:點到上邊的距離 
    $x2:點到左邊的距離 
    $y2:點到上邊的距離 
    $col:線段的顏色 
    $im = imagecreatetruecolor(200,200); 
    $red = imagecolorallocate($im,255,0,0); 
    imagerectangle($im,10,10,100,100,$red); 
    header('Content-type:image/png'); 
    imagepng($im); 
    */  

    //imagerotate — 用給定角度旋轉圖像  
    /*resource imagerotate ( resource $src_im , float $angle , int $bgd_color [, int $ignore_transparent ] ) 
    $src_im:資源圖片 
    $angle:旋轉的度數 
    $bgd_color:背景顏色 
    $source = imagecreatefromjpeg('1.jpg'); 
    $rotate = imagerotate($source,45, 26); 
    header('Content-type: image/jpeg'); 
    imagejpeg($rotate);  
    */  

    //imagesetpixel — 畫一個單一像素  
    /*bool imagesetpixel ( resource $image , int $x , int $y , int $color ) 
    $image:圖片資源 
    $x:點到左邊的距離 
    $y:點到上邊的距離 
    $color:點的顏色 
    $im = imagecreatetruecolor(100,100); 
    $red = imagecolorallocate($im,255,0,0); 
    imagesetpixel($im,50,50,$red); 
    header('Content-type: image/jpeg'); 
    imagejpeg($im);  
    */  

    //imagesetstyle — 設定畫線的風格  
    /*bool imagesetstyle ( resource $image , array $style ) 
    $image:圖片資源 
    $style:style 參數是像素組成的數組。下面的示例腳本在畫布上從左上角到右下角畫一行虛線:  
    header("Content-type: image/jpeg"); 
    $im  = imagecreatetruecolor(100, 100); 
    $w   = imagecolorallocate($im, 255, 255, 255); 
    $red = imagecolorallocate($im, 255, 0, 0); 
    $style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w); 
    imagesetstyle($im,$style); 
    imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED); 
    imagejpeg($im); 
    imagedestroy($im); 
    */  

    //imagestring — 水平地畫一行字符串  
    /*bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col ) 
    $image:圖片資源 
    $font:字體大小 
    $x:文字到左邊的距離 
    $y:文字到上邊的距離 
    $s:文字內容 
    $col:文字顏色 
    $im = imagecreatetruecolor(100,100); 
    $red = imagecolorallocate($im, 255, 0, 0); 
    imagestring($im,5,10,10,'helloworld',$red); 
    header("Content-type: image/jpeg"); 
    imagejpeg($im); 
    imagedestroy($im); 
    */  

    //imagestringup — 垂直地畫一行字符串  
    /*bool imagestringup ( resource $image , int $font , int $x , int $y , string $s , int $col ) 
    $image:圖片資源 
    $font:字體大小 
    $x:文字到左邊的距離 
    $y:文字到上邊的距離 
    $s:文字內容 
    $col:文字顏色 
    $im = imagecreatetruecolor(100,100); 
    $red = imagecolorallocate($im, 255, 0, 0); 
    imagestringup ($im,5,20,90,'helloworld',$red); 
    header("Content-type: image/jpeg"); 
    imagejpeg($im); 
    imagedestroy($im); 
    */  

    //imagesx — 取得圖像寬度  
    /*$im = imagecreatetruecolor(200,100); 
    echo imagesx($im); 
    */  

    //imagesy — 取得圖像長度  
    /*$im = imagecreatetruecolor(200,100); 
    echo imagesy($im); 
    */  

    //imagegd2 — 將 GD2 圖像輸出到瀏覽器或文件  
    //imagegd — 將 GD 圖像輸出到瀏覽器或文件  
    //imagegif — 以 GIF 格式將圖像輸出到瀏覽器或文件  
    //imagejpeg — 以 JPEG 格式將圖像輸出到瀏覽器或文件  
    //imagepng — 以 PNG 格式將圖像輸出到瀏覽器或文件  
    //imagewbmp — 以 WBMP 格式將圖像輸出到瀏覽器或文件  
    //imagexbm — 將 XBM 圖像輸出到瀏覽器或文件  
    /*以上都是函數如果有第二個參數那么會保存到文件上,如果沒有第二個參數則會輸出到瀏覽器上*/  

?>  </pre><br />
 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!