imagetypes

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

imagetypes返回 PHP 内置支持的图像类型

说明

imagetypes(): int

返回当前安装的 PHP 支持的图片类型。

参数

此函数没有参数。

返回值

返回链接到 PHP 的 GD 版本支持的图片类型相对应的位字段。返回以下位:IMG_AVIF | IMG_BMP | IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM | IMG_WEBP.

更新日志

版本 说明
8.1.0 新增 IMG_AVIF
7.2.0 新增 IMG_BMP
7.0.10 新增 IMG_WEBP

示例

示例 #1 检测 PNG 支持

<?php
if (imagetypes() & IMG_PNG) {
echo
"PNG Support is enabled";
}
?>

参见

  • gd_info() - 取得当前安装的 GD 库的信息
add a note add a note

User Contributed Notes 1 note

up
-4
ThunderCrew
16 years ago
Im not a smart man but this seemd to be the simplest code and it worked.
Its at the very top of this directory.

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

Returned image info and more.

array(11) { ["GD Version"]=> string(27) "bundled (2.0.28 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(false) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }
To Top