Return the image types supported by this PHP build
Syntax
imagetypes(): int
Return
Returns a bit-field corresponding to the image formats supported by the version of GD linked into PHP.
The following bits are returned:
Number | Image Type |
---|---|
1 | IMG_GIF |
2 | IMG_JPG |
4 | IMG_PNG |
8 | IMG_WBMP |
16 | IMG_XPM |
32 | IMG_WEBP |
64 | IMG_BMP |
128 | IMG_TGA |
256 | IMG_AVIF |
Examples
1 · return
<? $return = imagetypes(); echo $return; ?>
511
2 · supported
<? $return = imagetypes(); $array = array( IMG_GIF, IMG_JPG, IMG_PNG, IMG_WBMP, IMG_XPM, IMG_WEBP, IMG_BMP, IMG_TGA, IMG_AVIF ); echo "supported:" . PHP_EOL; for($i = 0; $i < count($array); ++$i) { if($return & $array[$i]) { echo $array[$i] . PHP_EOL; } } ?>
supported: 1 2 4 8 16 32 64 128 256