php 圖形處理函數imagetype_PHP教程

來源:互聯網
上載者:User
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 {...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.