<?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);*/
?>