PHP image width and height – Get image width and height in PHP
In this post, we will give you information about PHP image width and height – Get image width and height in PHP. Here we will give you detail about PHP image width and height – Get image width and height in PHP And how to use it also give you a demo for it if it is necessary.
In this quick tutorial, we are going to show you a simple way to get image width and height in PHP using the function getimagesize().
This is a very useful function in PHP, it provides a function to get the width and height of an image. The getimagesize() function will determine the size of image file including flash file(swf).
The getimagesize() function will determine the size of any supported given image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag and the correspondent HTTP content type.
list($width, $height, $type, $attr) = getimagesize("image_name.jpg");
All you need is the URL of an image or location to any image, then you can find the dimensions of an image like this:
list($width, $height, $type, $attr) = getimagesize("url/to/test.jpeg"); echo "Image width: ". $width; echo "<br>"; echo "Image height: ". $height; echo "<br>"; echo "Image type: ". $type; echo "<br>"; echo "Attribute: ". $attr;
When you run this script you will see the result like this
Result
Image width: 579 Image height 644 Image type: 2 Image Attribute: width="579" height="644"
Conclusion for PHP image width and height – Get image width and height in PHP
Hope this code and post will help you implement PHP image width and height – Get image width and height in PHP. If you need any help or any feedback give it in the comment section or if you have a good idea about this post you can give it in the comment section. Your comment will help us to help you more and improve us.