= 4.0.7, PHP 5, PHP 7, PHP 8)imagegd2 — 將 GD2 圖像輸出到瀏覽器或文件說(shuō)明imagegd2( resource $image, string $filename = ?, int $chunk_size =">

imagegd2

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

imagegd2將 GD2 圖像輸出到瀏覽器或文件

說(shuō)明

imagegd2(
    resource $image,
    string $filename = ?,
    int $chunk_size = ?,
    int $type = IMG_GD2_RAW
): bool

imagegd2() 將一個(gè) GD 圖像輸出到 filename。image

參數(shù)

image

由圖象創(chuàng)建函數(shù)(例如imagecreatetruecolor())返回的 GdImage 對(duì)象。

filename

文件保存的路徑或者已打開(kāi)的流資源(此方法返回后自動(dòng)關(guān)閉該流資源),如果未設(shè)置或?yàn)?null,將會(huì)直接輸出原始圖象流。

chunk_size

Chunk size.

type

可以是 IMG_GD2_RAWIMG_GD2_COMPRESSED。默認(rèn)為 IMG_GD2_RAW。

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false。

范例

示例 #1 輸出一個(gè) GD2 圖像

<?php
// Create a blank image and add some text
$im imagecreatetruecolor(12020);
$text_color imagecolorallocate($im2331491);
imagestring($im155,  "A Simple Text String"$text_color);

// Output the image
imagegd2($im);

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

示例 #2 保存 GD2 圖像

<?php
// Create a blank image and add some text
$im imagecreatetruecolor(12020);
$text_color imagecolorallocate($im2331491);
imagestring($im155,  "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 格式一般是用來(lái)加載圖像中的一部分時(shí)更快。注意 GD2 格式只能用于兼容于 GD2 的應(yīng)用程序。

更新日志

版本 說(shuō)明
4.3.2 添加了參數(shù) chunk_sizetype。

參見(jiàn)

  • imagegd() - 將 GD 圖像輸出到瀏覽器或文件