PHP Get Remote Image Width Height
Posted by in PHP February 15, 2012 Leave a comment

In order to get Width x Height of a remote image via its URL with PHP, we can use getimagesize() function. It also returns file type and sizes of the remote image.

Of course, this function works well with local image

Get Remote Image Width Height

<?php
list($width, $height) = getimagesize("http://cdn1.4rapiddev.com/wp-content/uploads/2011/04/Microsoft-SQL-Server-2008-Shrink.jpg"); 
echo "width: " . $width . " px" . "<br>";
echo "height: " . $height . " px" . "<br>";
?>

Output

width: 648 px
height: 415 px

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at hoan@4rapiddev.com