(PHP 4 >= 4.0.7, PHP 5)
imagegd2 — 將 GD2 圖像輸出到瀏覽器或文件
說明
bool imagegd2 ( resource$image
[, string $filename
[, int $chunk_size
[, int $type
= IMG_GD2_RAW
]]] )
imagegd2() 將一個 GD 圖像輸出到
filename
。image
參數
image
由圖象創建函數(例如imagecreatetruecolor())返回的圖象資源。
filename
文件保存的路徑,如果未設置或為 NULL
,將會直接輸出原始圖象流。
chunk_size
Chunk size.
type
可以是
IMG_GD2_RAW
或 IMG_GD2_COMPRESSED
。默認為
IMG_GD2_RAW
。
返回值
成功時返回 TRUE
, 或者在失敗時返回 FALSE
。
范例
Example #1 輸出一個 GD2 圖像
<?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 保存 GD2 圖像
<?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);
?>
注釋
Note: 此函數需要 GD 2.0.1 或更高版本(推薦 2.0.28 及更高版本)。
Note:
GD2 格式一般是用來加載圖像中的一部分時更快。注意 GD2 格式只能用于兼容于 GD2 的應用程序。
更新日志
版本
說明
4.3.2
添加了參數 chunk_size
和 type
。
參見
imagegd() - 將 GD 圖像輸出到瀏覽器或文件