取得當前安裝的 GD 庫的資訊

gd_info

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

gd_info — 取得當前安裝的 GD 庫的資訊

說明

gd_info(): array

獲取目前安裝的 GD 庫的版本和功能的資訊。

參數

此函式沒有參數。

返回值

返回一個關聯陣列。

gd_info() 返回的陣列元素
屬性含義
GD Version描述安裝的 libgd 的版本的 string 值。
FreeType Supportbool 值。如果安裝了 FreeType 支援則為 true。
FreeType Linkage 描述 FreeType 鏈接方式的 string 值。 可能值為:'with freetype'、'with TTF library' 和 'with unknown library'。 僅當 FreeType Support 為 true 時才會有該屬性。
GIF Read Support bool 值。 如果支援 讀取 GIF 影象, 則為 true。
GIF Create Support bool 值。 如果支援 建立 GIF 影象, 則為 true。
JPEG Support bool 值。 如果支援 JPEG 則為 true。
PNG Support bool 值。 如果支援 PNG 則為 true。
WBMP Support bool 值。 如果支援 WBMP 則為 true。
XBM Support bool 值。 如果支援 XBM 則為 true。
WebP Support bool 值。 如果支援 WebP 則為 true。
AVIF Support bool 值。 如果支援 AVIF 則為 true。 從 PHP 8.1.0 開始可用。

範例

示例 #1 使用 gd_info()

<?php
var_dump
(gd_info());
?>

以上例程的輸出類似於:

array(10) {
  ["GD Version"]=>
  string(24) "bundled (2.1.0 compatible)"
  ["FreeType Support"]=>
  bool(false)
  ["GIF Read Support"]=>
  bool(true)
  ["GIF Create Support"]=>
  bool(false)
  ["JPEG Support"]=>
  bool(false)
  ["PNG Support"]=>
  bool(true)
  ["WBMP Support"]=>
  bool(true)
  ["XBM Support"]=>
  bool(false)
  ["WebP Support"]=>
  bool(false)
  ["AVIF Support"]=>
  bool(false)
}

參見

  • imagepng() - 以 PNG 格式將影象輸出到瀏覽器或檔案
  • imagejpeg() - 輸出圖像到瀏覽器或檔案。
  • imagegif() - 輸出圖像到瀏覽器或檔案。
  • imagewbmp() - 以 WBMP 格式將影象輸出到瀏覽器或檔案
  • imagewebp() - 將 WebP 格式的影象輸出到瀏覽器或檔案
  • imageavif() - 輸出圖像到瀏覽器或檔案。
  • imagetypes() - 返回目前 PHP 版本所支援的影象型別

Leave a Reply

Your email address will not be published. Required fields are marked *