Get Image Height and Width in PHP

In this tutorial, we will learn how to get the image width and height in php. We will use getimagesize() function to implement it.

Here is an example.

<?php
$imgsize_arr = getimagesize('image/image_file.jpg');
$img_width = $imgsize_arr[0];
$img_height = $imgsize_arr[1];
echo "Image width: ".$img_width."<br/>Image height:".$img_height;
?>