phpimagedimensions

Get image dimensions


I have an url to the image, like $var = http://example.com/image.png

How do I get its dimensions to an array, like array([h]=> 200, [w]=>100) (height=200, width=100)?


Solution

  • You can use the getimagesize function like this:

    list($width, $height) = getimagesize('path to image');
    echo "width: " . $width . "<br />";
    echo "height: " .  $height;