php教程 圖形處理函數imagetypes() imagecreatetruecolor() imagecreate()
//判斷當前的gd庫是否支援png
if(imagetypes() & img_png)
{
echo "png support is enabled";
}
else
{
echo "png support is disabled";
}
/*
int imagetypes ( void )
本函數以位元欄位方式返回與當前 php 版本關聯的 gd 庫所支援的映像格式。將返回以下結果,img_gif | img_jpg | img_png | img_wbmp| img_xpm。 例如要檢查是否支援 png
*/
//建立映像
$img=imagecreatetruecolor(300,200);
//取得映像寬度
echo imagesx($img);
/*
看個執行個體
*/
//建立一幅 100x30 的映像
$im=imagecreate(100,30);
//白色背景和藍色文本
$bg=imagecolorallocate($im,255,255,255);
$textcolor=imagecolorallocate($im,0,0,255);
//把字串寫在映像左上方
imagestring($im,5,0,0,"hello world!",$textcolor);
//輸出映像
header("content-type: image/png");
imagepng($im);
/*
如果你想建立一個png映像*透明*,其中的背景是完全透明的,所有行動發生在借鑒,除此之外,然後執行下列操作:
*/
$png = imagecreatetruecolor(800, 600);
imagesavealpha($png, true);
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
imagefill($png, 0, 0, $trans_colour);
$red = imagecolorallocate($png, 255, 0, 0);
imagefilledellips教程教程e($png, 400, 300, 400, 300, $red);
header("content-type: image/png");
imagepng($png);
http://www.bkjia.com/PHPjc/631351.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631351.htmlTechArticlephp教程 圖形處理函數imagetypes() imagecreatetruecolor() imagecreate() //判斷當前的gd庫是否支援png if(imagetypes() img_png) { echo png support is enabled; } else {...