I've tried to use the PHP function getimagesize, but I was unable to extract the image width and height as an integer value.
How can I achieve this?
I've tried to use the PHP function getimagesize, but I was unable to extract the image width and height as an integer value.
How can I achieve this?
Try like this:
list($width, $height) = getimagesize('path_to_image');
Make sure that:
Also try to prefix path with $_SERVER["DOCUMENT_ROOT"], this helps sometimes when you are not able to read files.
getimagesize() on remote images.Like this :
imageCreateFromPNG($var);
//I don't know where from you get your image, here it's in the png case
// and then :
list($width, $height) = getimagesize($image);
echo $width;
echo $height;
getimagesize() expects parameter 1 to be string, resource given, function getimagesize expects filenamePHP's getimagesize() returns an array of data. The first two items in the array are the two items you're interested in: the width and height. To get these, you would simply request the first two indexes in the returned array:
var $imagedata = getimagesize("someimage.jpg");
print "Image width is: " . $imagedata[0];
print "Image height is: " . $imagedata[1];
For further information, see the documentation.