views:

28

answers:

2

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

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

+4  A: 

You can use the getimagesize function like this:

list($width, $height) = getimagesize('path to image');
echo "width: $width <br />";
echo "height: $height";
Sarfraz
OP did ask "How do I get its dimensions to an array" so Im not sure why this is the fully accepted answer... GJ though.
Dutchie432
@Dutchie432: He mainly meant how to get image dimensions and creating an array once you have width and height is/should be easy :)
Sarfraz
I think it's safe to say that's your (likely correct) assumption, and not addressing the specifics of the question.
Dutchie432
+2  A: 
<?php 
    list($width, $height) = getimagesize("http://site.com/image.png"); 
    $arr = array('h' => $height, 'w' => $width );
?>
Dutchie432