imagegd2
(PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8)
imagegd2 — 將 GD2 影象輸出到瀏覽器或檔案
說明
   imagegd2(
resource
string
int
int
): bool
  resource
$image,string
$filename = ?,int
$chunk_size = ?,int
$type = IMG_GD2_RAW): bool
   imagegd2() 將一個 GD 影象輸出到
   filename。image
  
參數
- 
image
- 
由圖像建立函式(例如imagecreatetruecolor())返回的 GdImage 對象。 
- 
filename
- 
      檔案儲存的路徑或者已打開的流資源(此方法返回后自動關閉該流資源),如果未設定或為 null,將會直接輸出原始圖像流。
- 
chunk_size
- 
      Chunk size. 
- 
type
- 
      可以是 IMG_GD2_RAW或IMG_GD2_COMPRESSED。預設為IMG_GD2_RAW。
返回值
   成功時返回 true, 或者在失敗時返回 false。
  
範例
示例 #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);
?>
示例 #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);
?>
註釋
注意:
GD2 格式一般是用來載入影象中的一部分時更快。注意 GD2 格式只能用於相容于 GD2 的應用程式。
更新日誌
| 版本 | 說明 | 
|---|---|
| 4.3.2 | 新增了參數 chunk_size和type。 |