Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

image_​type_​to_​mime_​type

Description

Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype

Syntax

image_type_to_mime_type(
    int $image_type
): string

Parameters

image_type

One of the IMAGETYPE_XXX constant.

Return

The returned values are as follows:

NumberImage TypeMIME Type
1IMAGETYPE_GIFimage/gif
2IMAGETYPE_JPEGimage/jpeg
3IMAGETYPE_PNGimage/png
4IMAGETYPE_SWFapplication/x-shockwave-flash
5IMAGETYPE_PSDimage/psd
6IMAGETYPE_BMPimage/bmp
7IMAGETYPE_TIFF_II (intel byte order)image/tiff
8IMAGETYPE_TIFF_MM (motorola byte order)image/tiff
9IMAGETYPE_JPCapplication/octet-stream
10IMAGETYPE_JP2image/jp2
11IMAGETYPE_JPXapplication/octet-stream
12IMAGETYPE_JB2application/octet-stream
13IMAGETYPE_SWCapplication/x-shockwave-flash
14IMAGETYPE_IFFimage/iff
15IMAGETYPE_WBMPimage/vnd.wap.wbmp
16IMAGETYPE_XBMimage/xbm
17IMAGETYPE_ICOimage/vnd.microsoft.icon
18IMAGETYPE_WEBPimage/webp
19IMAGETYPE_AVIFimage/avif

Examples

1 · image_type

<?

$image_type = IMAGETYPE_PNG;

$return = image_type_to_mime_type($image_type);

echo $return;

?>
image/png

2 · MIME types

<?

for($i = 1; $i <= 19; ++$i)
{
    echo $i . ' ' . image_type_to_mime_type($i) . PHP_EOL;
}

?>
1 image/gif
2 image/jpeg
3 image/png
4 application/x-shockwave-flash
5 image/psd
6 image/bmp
7 image/tiff
8 image/tiff
9 application/octet-stream
10 image/jp2
11 application/octet-stream
12 application/octet-stream
13 application/x-shockwave-flash
14 image/iff
15 image/vnd.wap.wbmp
16 image/xbm
17 image/vnd.microsoft.icon
18 image/webp
19 image/avif
HomeMenu