image_type_to_mime_type
Description
The image_type_to_mime_type of Image for PHP 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:
Value | Image Type | MIME Type |
---|---|---|
1 | IMAGETYPE_GIF | image/gif |
2 | IMAGETYPE_JPEG | image/jpeg |
3 | IMAGETYPE_PNG | image/png |
4 | IMAGETYPE_SWF | application/x-shockwave-flash |
5 | IMAGETYPE_PSD | image/psd |
6 | IMAGETYPE_BMP | image/bmp |
7 | IMAGETYPE_TIFF_II (intel byte order) | image/tiff |
8 | IMAGETYPE_TIFF_MM (motorola byte order) | image/tiff |
9 | IMAGETYPE_JPC | application/octet-stream |
10 | IMAGETYPE_JP2 | image/jp2 |
11 | IMAGETYPE_JPX | application/octet-stream |
12 | IMAGETYPE_JB2 | application/octet-stream |
13 | IMAGETYPE_SWC | application/x-shockwave-flash |
14 | IMAGETYPE_IFF | image/iff |
15 | IMAGETYPE_WBMP | image/vnd.wap.wbmp |
16 | IMAGETYPE_XBM | image/xbm |
17 | IMAGETYPE_ICO | image/vnd.microsoft.icon |
18 | IMAGETYPE_WEBP | image/webp |
19 | IMAGETYPE_AVIF | image/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) { $return = image_type_to_mime_type($i); echo "$i: $return\n"; } ?>
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
Links
Image
- gd_info
- getimagesize
- getimagesizefromstring
- image_type_to_extension
- image_type_to_mime_type
- imageaffine
- imageaffinematrixconcat
- imageaffinematrixget
- imagealphablending
- imageantialias
- imagearc
- imageavif
- imagebmp
- imagechar
- imagecharup
- imagecolorallocate
- imagecolorallocatealpha
- imagecolorat
- imagecolorclosest
- imagecolorclosestalpha
- imagecolorclosesthwb
- imagecolordeallocate
- imagecolorexact
- imagecolorexactalpha
- imagecolormatch
- imagecolorresolve
- imagecolorresolvealpha
- imagecolorset
- imagecolorsforindex
- imagecolorstotal
- imagecolortransparent
- imageconvolution
- imagecopy
- imagecopymerge
- imagecopymergegray
- imagecopyresampled
- imagecopyresized
- imagecreate
- imagecreatefromavif
- imagecreatefrombmp
- imagecreatefromgif
- imagecreatefromjpeg
- imagecreatefrompng
- imagecreatefromstring
- imagecreatefromtga
- imagecreatefromwbmp
- imagecreatefromwebp
- imagecreatefromxbm
- imagecreatefromxpm
- imagecreatetruecolor
- imagecrop
- imagecropauto
- imagedashedline
- imagedestroy
- imageellipse
- imagefill
- imagefilledarc
- imagefilledellipse
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagefilter
- imageflip
- imagefontheight
- imagefontwidth
- imageftbbox
- imagefttext
- imagegammacorrect
- imagegetclip
- imagegetinterpolation
- imagegif
- imageinterlace
- imageistruecolor
- imagejpeg
- imagelayereffect
- imageline
- imageloadfont
- imageopenpolygon
- imagepalettecopy
- imagepalettetotruecolor
- imagepng
- imagepolygon
- imagerectangle
- imageresolution
- imagerotate
- imagesavealpha
- imagescale
- imagesetbrush
- imagesetclip
- imagesetinterpolation
- imagesetpixel
- imagesetstyle
- imagesetthickness
- imagesettile
- imagestring
- imagestringup
- imagesx
- imagesy
- imagetruecolortopalette
- imagettfbbox
- imagettftext
- imagetypes
- imagewbmp
- imagewebp
- imagexbm
- iptcembed
- iptcparse