Get image dimensions [duplicate] Get image dimensions [duplicate] php php

Get image dimensions [duplicate]


You can use the getimagesize function like this:

list($width, $height) = getimagesize('path to image');echo "width: " . $width . "<br />";echo "height: " .  $height;


Using getimagesize function, we can also get these properties of that specific image-

<?phplist($width, $height, $type, $attr) = getimagesize("image_name.jpg");echo "Width: " .$width. "<br />";echo "Height: " .$height. "<br />";echo "Type: " .$type. "<br />";echo "Attribute: " .$attr. "<br />";//Using array$arr = array('h' => $height, 'w' => $width, 't' => $type, 'a' => $attr);?>


Result like this -

Width: 200
Height: 100
Type: 2
Attribute: width='200' height='100'


Type of image consider like -

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


<?php     list($width, $height) = getimagesize("http://site.com/image.png");     $arr = array('h' => $height, 'w' => $width );?>