php8.5
Home/ Manual/ image / functions/ image_type_to_mime_type

image_type_to_mime_type

PHP function Edit on GitHub ✎

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

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

Description

image_type_to_mime_type(int $image_type): string

The image_type_to_mime_type() function will determine the Mime-Type for an IMAGETYPE constant.

Parameters

image_type

One of the IMAGETYPE_* constants.

Return Values

The returned values are as follows

image_typeReturned value
IMAGETYPE_GIFimage/gif
IMAGETYPE_JPEGimage/jpeg
IMAGETYPE_PNGimage/png
IMAGETYPE_SWFapplication/x-shockwave-flash
IMAGETYPE_PSDimage/psd
IMAGETYPE_BMPimage/bmp
IMAGETYPE_TIFF_II (intel byte order)image/tiff
IMAGETYPE_TIFF_MM (motorola byte order)image/tiff
IMAGETYPE_JPCapplication/octet-stream
IMAGETYPE_JP2image/jp2
IMAGETYPE_JPXapplication/octet-stream
IMAGETYPE_JB2application/octet-stream
IMAGETYPE_SWCapplication/x-shockwave-flash
IMAGETYPE_IFFimage/iff
IMAGETYPE_WBMPimage/vnd.wap.wbmp
IMAGETYPE_XBMimage/xbm
IMAGETYPE_ICOimage/vnd.microsoft.icon
IMAGETYPE_WEBPimage/webp
IMAGETYPE_AVIFimage/avif
IMAGETYPE_HEIFimage/heif

Examples

image_type_to_mime_type() example

php
<?php
header("Content-type: " . image_type_to_mime_type(IMAGETYPE_PNG));
?>

Notes Notrequired

See Also

Source: reference/image/functions/image-type-to-mime-type.xml · from the official PHP manual (php/doc-en)