image_type_to_mime_type 


php apg

GETS the MIME-Type for image-type returned by various PHP functions.


This function does not require the GD image library.

Included in this section for being in common use.





  MIME-Type   

A media type (formerly known as MIME-type) is a two-part identifier for file formats and format contents transmitted on the Internet.

The Internet Assigned Numbers Authority (IANA) is the official authority for the standardization and publication of these classifications.

Media types were originally defined in Request for Comments RFC 2045 (MIME) Part One: Format of Internet Message Bodies (Nov 1996) in November 1996 as a part of MIME (Multipurpose Internet Mail Extensions) specification, for denoting type of email message content and attachments; hence the original name, MIME-type.

Media types are also used by other internet protocols such as HTTP and document file formats such as HTML, for similar purposes.

From Wikipedia, the free encyclopedia.



<?php

string image_type_to_mime_type 
int $image_type )

where,

$image_type One of the IMAGETYPE_ constants
                       
SEE the below TABLE )

?>

  $image_type   

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


  1 EXERCISE   

<?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>';
}
    
}

?>

 RESULT   

See the results of this exercise on the version of PHP you have installed.