php getting image type of remote image

$url_image = ...
$headers = get_headers($url_image);
    foreach($headers as $key => $value)
    {
        $buf = explode(":",$headers[$key]);
        if($buf[0] == "Content-Type")
        {
            $buf = explode("/",$buf[1]);
            $extension = $buf[1];
        }
    }

Related posts:

This entry was posted in php. Bookmark the permalink.