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?
Answer: Use the JavaScript clientWidth property You can simply use the JavaScript clientWidth property to get the current width and height of an image. This property will round the value to an integer.
The getimagesize() function in PHP is an inbuilt function which is used to get the size of an image. This function accepts the filename as a parameter and determines the image size and returns the dimensions with the file type and height/width of image.
width(); alert(imageWidth); var imageHeight = Imgsize. height();
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.
list($width, $height) = getimagesize($filename)
Or,
$data = getimagesize($filename); $width = $data[0]; $height = $data[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With