PHP | imagetypes() Function

The imagetypes() function is an inbuilt function in PHP which is used to return the image types supported by the PHP inbuilt installed library.

Syntax:

int imagetypes( void )

Parameters: This function does not accept any parameter.



Return Value: This function returns the bit-field corresponding to the image formats supported by the version of GD linked into PHP. This function returns the following bits: IMG_BMP, IMG_GIF, IMG_JPG, IMG_PNG, IMG_WBMP, IMG_XPM, IMG_WEBP.

Below programs illustrate the imagetypes() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
if (imagetypes() & IMG_PNG) {
    echo "PNG Support is enabled";
}
else {
    echo "Not supported image type.";
}
?>

chevron_right


Output:

PNG Support is enabled

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
if (imagetypes() & IMG_JPEG) {
    echo "JPEG Support is enabled";
}
else {
    echo "Not supported image type.";
}
?>

chevron_right


Output:

JPEG Support is enabled

Related Articles:

Reference: http://php.net/manual/en/function.imagetypes.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : Akanksha_Rai