php gd庫 相關教程 :
1.PHP開發浮水印與縮圖教程
2.PHP浮水印與縮圖最新視頻教程
3.php圖片處理 gd2設定檔修改
//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 cornerimagechar($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 backgroundimagecharup($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
以上就是php-GD庫的函數(一)_GD庫教程的內容,更多相關內容請關注topic.alibabacloud.com(www.php.cn)!