首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

imagegd

(PHP 4 >= 4.0.7, PHP 5, PHP 7)

imagegd - 将GD图像输出到浏览器或文件

描述

代码语言:javascript
复制
bool imagegd ( resource $image [, mixed $to = NULL ] )

输出GD图像给给定的to

参数

代码语言:txt
复制
`image`   

一个图像资源,由图像创建函数之一返回,如imagecreatetruecolor()。

to

路径或打开的流资源(在此函数返回后自动关闭)将文件保存到。如果没有设置或者NULL,原始图像流将被直接输出。

返回值

返回TRUE成功或失败时返回FALSE

更新日志

描述

7.2.0

imagegd()现在允许输出truecolor图像。以前,这些已被隐式转换为调色板。

5.4.0

增加了对将流资源传递给to的支持。

例子

Example #1 Outputting a GD image

代码语言:javascript
复制
<?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
imagegd($im);

// Free up memory
imagedestroy($im);
?>

Example #2 Saving a GD image

代码语言:javascript
复制
<?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 gd image
// The file format for GD images is .gd, see http://www.libgd.org/GdFileFormats
imagegd($im, 'simple.gd');

// Free up memory
imagedestroy($im);
?>

注释

注意:GD格式通常用于快速加载部分图像。请注意,GD格式仅适用于兼容GD的应用程序。

← imagegd2

imagegetclip →

扫码关注腾讯云开发者

领取腾讯云代金券