函数名:imagegd()
适用版本:PHP 4、PHP 5、PHP 7
函数描述: imagegd() 函数将图像以 GD 1.x 格式保存到指定的文件或浏览器。
语法: bool imagegd ( resource $image [, mixed $to [, int $threshold = -1 ]] )
参数:
返回值: 成功时返回 true,失败时返回 false。
示例:
$image = imagecreatetruecolor(200, 200);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
$filename = 'output.gd';
if (imagegd($image, $filename)) {
echo '图像保存成功!';
} else {
echo '图像保存失败!';
}
$image = imagecreatetruecolor(200, 200);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
header('Content-Type: image/png');
imagegd($image);
注意事项: