imagegd2
(PHP 4 >= 4.0.7, PHP 5, PHP 7)
imagegd2 - 将GD2图像输出到浏览器或文件
描述
bool imagegd2 ( resource $image [, mixed $to = NULL [, int $chunk_size = 128 [, int $type = IMG_GD2_RAW ]]] )
输出一个GD2图像给给定的to
。
参数
`image`
一个图像资源,由图像创建函数之一返回,如imagecreatetruecolor()。
to
路径或打开的流资源(在此函数返回后自动关闭)将文件保存到。如果没有设置或者NULL
,原始图像流将被直接输出。
chunk_size
块大小。
type
无论是IMG_GD2_RAW
或IMG_GD2_COMPRESSED
。默认是IMG_GD2_RAW
。
返回值
返回TRUE
成功或FALSE
失败时返回。
更新日志
版 | 描述 |
---|---|
5.4.0 | 增加了对将流资源传递给to的支持。 |
例子
Example #1 Outputting a GD2 image
<?php
//?Create?a?blank?image?and?add?some?text
$im?=?imagecreatetruecolor(120,?20);
$text_color?=?imagecolorallocate($im,?233,?14,?91);
imagestring($im,?1,?5,?5,??"A?Simple?Text?String",?$text_color);
//?Output?the?image
imagegd2($im);
//?Free?up?memory
imagedestroy($im);
?>
Example #2 Saving a GD2 image
<?php
//?Create?a?blank?image?and?add?some?text
$im?=?imagecreatetruecolor(120,?20);
$text_color?=?imagecolorallocate($im,?233,?14,?91);
imagestring($im,?1,?5,?5,??"A?Simple?Text?String",?$text_color);
//?Save?the?gd2?image
//?The?file?format?for?GD2?images?is?.gd2,?see?http://www.libgd.org/GdFileFormats
imagegd2($im,?'simple.gd2');
//?Free?up?memory
imagedestroy($im);
?>
注释
注:GD2格式通常用于快速加载部分图像。请注意,GD2格式仅适用于GD2兼容的应用程序。
← imagegammacorrect
imagegd →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com