Friday, October 24, 2025
HomeLanguagesPHP | imagetypes() Function

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:




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


Output:

PNG Support is enabled

Program 2:




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


Output:

JPEG Support is enabled

Related Articles:

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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS