How to get the Dimensions of an Image using PHP

How to get the Dimensions of an Image using PHP

PHP has a very interesting function to obtain information about images: getimagesize () .

With this feature which facilitates the PHP library you can find out the size of an image file, the dimensions (width, height), and file type (gif, jpg, png, etc …) and attributes (width = “” height = “”) with the height / width to be used within the IMG HTML tag).

Image types returned by the function :

1 = GIF 5 = PSD 9 = JPC 13 = SWC
2 = JPG 6 = BMP 10 = JP2 14 = IFF
3 = PNG 7 = TIFF 11 = JPX 15 = WBMP
4 = SWF 8 = TIFF 12 = JB2 16 = XBM

Characteristics of the sample image obtained with the getimagesize () function

list($width, $height, $type, $attr) = getimagesize("php-logo.png");
echo "Width:" $ width;.
echo "Height: " .$height;
echo "Type: " .$type;
echo "Attributes: " .$attr;

Result:

Width: 397
Height: 255
Type: 3
Attributes: width = “397” height = “255”

Lucid Kit

Related Posts
Leave a reply
Captcha Click on image to update the captcha .