Get any uploaded image height and width in PHP from URL,Path

How to find image width and height in pixels using $getimagesize(ImageName) method.

In this tutorial we are creating a simple php programming code for detect any already uploaded image file width and height in pixels because some time web developer needs to apply some kind of image uploading restrictions like you have to upload image minimum size of 200 × 200 pixels or more like it. Then with the use of this simple code website developer can easily detect and find out what image size is. So here is the complete step by step tutorial for Get any uploaded image height and width in PHP from URL,Path.

android-project-download-code-button

How to Get any uploaded image height and width in PHP from URL,Path.

Code for image-width-height.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>

<?php

//Pass your image path here.
$image_path = 'https://www.android-examples.com/wp-content/uploads/2016/03/android-tutorials.png';


list($Image_width, $Image_height) = getimagesize($image_path);


echo "Image Width = " . $Image_width ."px" . '</br>';
echo "Image Height = " . $Image_height . "px" ;

?>

</body>
</html>

Screenshot:

Get any uploaded image height and width in PHP from URL,Path

Click here to download Get any uploaded image height and width in PHP from URL,Path project file with source code.

Leave a Reply

Your email address will not be published. Required fields are marked *