<?php
string image_type_to_mime_type ( int $image_type )
where,
$image_type = One of the IMAGETYPE_ constants
( SEE the below TABLE )
?>
The IMAGETYPE_XXX constants. | ||
CONSTANT | VALUE | MEANING |
IMAGETYPE_GIF | 1 | image/gif |
IMAGETYPE_JPEG | 2 | image/jpeg |
IMAGETYPE_PNG | 3 | image/png |
IMAGETYPE_SWF | 4 | application/x-shockwave-flash |
IMAGETYPE_PSD | 5 | image/psd |
IMAGETYPE_BMP | 6 | image/bmp |
IMAGETYPE_TIFF_II (Intel byte order) |
7 | image/tiff |
IMAGETYPE_TIFF_MM (Motorola byte order) |
8 | image/tiff |
IMAGETYPE_JPC | 9 | application/octet-stream |
IMAGETYPE_JP2 | 10 | image/jp2 |
IMAGETYPE_JPX | 11 | application/octet-stream |
IMAGETYPE_JB2 | 12 | application/octet-stream |
IMAGETYPE_SWC | 13 | application/x-shockwave-flash |
IMAGETYPE_IFF | 14 | image/iff |
IMAGETYPE_WBMP | 15 | image/vnd.wap.wbmp |
IMAGETYPE_XBM | 16 | image/xbm |
IMAGETYPE_ICO | 17 | image/vnd.microsoft.icon |
IMAGETYPE_WEBP | 18 | image/webp |
IMAGETYPE_AVIF (Since PHP 8.1.0) |
19 | image/avif |
ed48 |
<?php
if(PHP_VERSION_ID < 80100)
{
for ($x = 1; $x <= 18; $x++)
{
echo $x . ' = ' . image_type_to_mime_type($x) . '<br>';
}
}
else
{
for ($x = 1; $x <= 19; $x++)
{
echo $x . ' = ' . image_type_to_mime_type($x) . '<br>';
}
}
?>