imagetypes 


gd apg

RETURN the image types supported by this PHP build.



<?php

int imagetypes 
()

?>

IMAGE TYPES


This function outputs ERROR if any improper constant is used.

IMAGE TYPE CONSTANTS
CONSTANT VALUE MEANING
IMG_GIF 1 GIF IMAGES
IMG_JPG 2 JPEG IMAGES
IMG_JPEG
IMG_PNG 4 PNG IMAGES
IMG_WBMP 8 WBMP IMAGES
IMG_XPM 16 XPM IMAGES
IMG_WEBP 32 WEBP IMAGES
IMG_BMP 64 BMP IMAGES
IMG_TGA 128 TGA IMAGES
As of PHP 7.4.0
IMG_AVIV 256 AVIF IMAGES
As of PHP 8.1.0
ed48


  1 EXERCISE   

<?php

// Run this code to see the result

echo 'PHP ' PHP_VERSION '<br><br>';

if(
PHP_VERSION_ID <= 80100)
{
$imgtypes01 =  [ "IMG_GIF" => IMG_GIF
"IMG_JPG" => IMG_JPG"IMG_JPEG" => IMG_JPEG,
"IMG_PNG" => IMG_PNG"IMG_WBMP" => IMG_WBMP
"IMG_XPM" => IMG_XPM"IMG_WEBP" => IMG_WEBP
"IMG_BMP" => IMG_BMP"IMG_TGA" => IMG_TGA ];
}
else
{        
$imgtypes01 =  [ "IMG_GIF" => IMG_GIF
"IMG_JPG" => IMG_JPG"IMG_JPEG" => IMG_JPEG
"IMG_PNG" => IMG_PNG"IMG_WBMP" => IMG_WBMP
"IMG_XPM" => IMG_XPM"IMG_WEBP" => IMG_WEBP
"IMG_BMP" => IMG_BMP"IMG_TGA" => IMG_TGA
"IMG_AVIF" => IMG_AVIF ];
}
foreach(
$imgtypes01 as $kt => $vt)
{   
    echo 
$kt ' => ';
    
var_dump((imagetypes() & $vt));
    echo 
'<br>';
}

?>

  2 EXERCISE   

<?php

// Run this code to see the result

echo 'PHP ' PHP_VERSION '<br><br>';

if(
PHP_VERSION_ID <= 80100)
{

$imgtypes01 =  [ => IMG_GIF
=> IMG_JPG=> IMG_JPEG,
=> IMG_PNG=> IMG_WBMP
16 => IMG_XPM32 => IMG_WEBP
64 => IMG_BMP128 => IMG_TGA ];
}
else
{        
$imgtypes01 =  [ => IMG_GIF
=> IMG_JPG=> IMG_JPEG,
=> IMG_PNG=> IMG_WBMP
16 => IMG_XPM32 => IMG_WEBP
64 => IMG_BMP128 => IMG_TGA
256 => IMG_AVIF ];
}
foreach(
$imgtypes01 as $kt => $vt)
{   
    echo 
$kt ' => ';
    
var_dump((imagetypes() & $vt));
    echo 
'<br>';
}

?>