Getting dimensions of a remote image
Another straight to the point solution
The code below works on GIF, JPEG and PNG images. It returns width & height but also file extension.$url = 'http://en.wikipedia.org/static/images/project-logos/enwiki.png';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/image_info.php?url=' . $url));
if (!$data->success)
{
echo 'Failed';
}
else
{
echo 'width: ' . $data->width;
echo 'width: ' . $data->height;
echo 'extension: ' . $data->ext;
}
Comments