函数名:imagegd2()
适用版本:PHP 4 >= 4.0.7, PHP 5, PHP 7
用法:imagegd2() 函数将图像以 GD2 格式输出到浏览器或保存到文件中。
语法:bool imagegd2 ( resource $image [, mixed $to [, int $chunk_size [, int $type = IMG_GD2_RAW ]] )
参数:
返回值:成功时返回 true,失败时返回 false。
示例1:输出图像到浏览器
// 创建一个图像资源
$image = imagecreatefromjpeg('test.jpg');
// 输出图像到浏览器
header('Content-Type: image/gd2');
imagegd2($image);
// 释放图像资源
imagedestroy($image);
示例2:保存图像到文件
// 创建一个图像资源
$image = imagecreatefrompng('test.png');
// 保存图像到文件
imagegd2($image, 'output.gd2');
// 释放图像资源
imagedestroy($image);
注意事项:
更多信息和示例代码可以参考 PHP 官方文档:https://www.php.net/manual/en/function.imagegd2.php