Home > php教程 > php手册 > body text

php 图形处理函数imagetype

WBOY
Release: 2016-06-13 10:03:32
Original
1528 people have browsed it

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);
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template