use imagetypes() function to check which image types are supported.This function returns a bit field which returns a bit field you can use bitwise AND operator to check if a given bit is set.Constants IMG_JPG,IMG_GIF ,IMG_PNG correspond to the bit for image formats.
Example of a code segment ;
<?php
$image=imagecreate(200,200);
$white=imagecolorallocate($image,0xFF,0XFF,0XFF);
$black=imagecolorallocate($image,0X00,0X00,0X00);
imagefieldrectangle=($image,50,50,150,150,$black);
if(imagetypes() &IMG_PNG)
{
header("Content-Type:image/png)
imagepng($image);
} elseif
{
//same for other formats
}
?>