In last week while performing my task I had a requirement to get image height and width dynamically with PHP programming. To satisfy that requirement I had searched the web and found the optimum way to do so, that I want to discuss here.
PHP provides an inbuilt function named getimagesize() to get the size of an image.
The getimagesize() function accepts one argument i.e. image path and returns an array with 7 elements.
array getimagesize (string $filepath)
The returning array consist dimensions of given image file along with the file type.
Index 0 and 1 indicates the width and height of the image respectively.
Index 2 is the constant indicating the type of the image.
Index 3 is a text string with the height=”yyyy” width=”xxxx” string.
The last argument mime is the correspondent MIME type of an image.
Hope this will help you.