php 图形处理函数imagetype
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.phprm.com/base/36652.html
随意转载^^但请附上教程地址。