'.png' ,'type' => 'raster' ,'mime' => 'image/png' ,'loss' => 'lossless' ]; } if (substr($image_bin,0,2)==chr(255).chr(216)) { return [ 'ext' => '.jpg,.jpeg,.jpe,.jif,.jfif,.jfi' ,'type' => 'raster' ,'mime' => 'image/jpeg' ,'loss' => 'lossy' ]; } if (substr($image_bin,0,2)==chr(66).chr(77) || substr($image_bin,0,2)==chr(66).chr(65) || substr($image_bin,0,2)==chr(67).chr(73) || substr($image_bin,0,2)==chr(73).chr(67)) { return [ 'ext' => '.bmp,.dib' ,'type' => 'raster' ,'mime' => 'image/x-bmp' ,'loss' => 'lossless' ]; } if (substr($image_bin,0,6)==chr(71).chr(73).chr(70).chr(56).chr(55).chr(97) || substr($image_bin,0,6)==chr(71).chr(73).chr(70).chr(56).chr(57).chr(97)) { return [ 'ext' => '.gif' ,'type' => 'raster' ,'mime' => 'image/x-bmp' ,'loss' => 'palette' ]; } return false; } // Usage if (!$ftype = identify_image("png.png")) die ("Cannot Identify Image Type"); else { echo "
"; print_r($ftype); }