Get Image Height Width using PHP
The getimagesize() function will determine the size of any given image file including flash file(swf) 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 correspondant HTTP content type.
Syntax
list($width, $height, $type, $attr) = getimagesize("myPic.jpg");
This is a sample code, change myPic to your image name and test it!
<?php
list($width, $height, $type, $attr) = getimagesize(" myPic.png");
echo "Image width " .$width;
echo "<br />";
echo "Image height " .$height;
echo "<br />";
echo "Image type " .$type;
echo "<br />";
echo "Attribute " .$attr;
?>
list($width, $height, $type, $attr) = getimagesize(" myPic.png");
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
Image width 365
Image height 255
Image type 3
Image attribute width="365" height="255"
You will get the width, height, type of an image and also attribute of an image,. Image height 255
Image type 3
Image attribute width="365" height="255"
Type of an image you can see from table below
| 1 = GIF | 2 = JPG | 3 = PNG | 4 = SWF |
| 5 = PSD | 6 = BMP | 7 = TIFF(intel byte order) | 8 = TIFF(motorola byte order) |
| 9 = JPC | 10 = JP2 | 11 = JPX | 12 = JB2 |
| 13 = SWC | 14 = IFF | 15 = WBMP | 16 = XBM |
