Php Getimagesize
# PHP getimagesize Function - Get Image Information
[PHP Image Processing](#)
The getimagesize() function is used to get the size and related information of an image. On success, it returns an array; on failure, it returns FALSE and generates an E_WARNING level error message.
Syntax:
array getimagesize ( string $filename [, array &$imageinfo ] )
The getimagesize() function will determine the size of any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM, or WBMP image file and return the image dimensions, file type, and image height and width.
### Example 1: Local Image File
The output of the above example is:
Width: 290Height: 69Type: 3Attribute: width="290" height="69"
### Example 2: Remote Image File
The output of the above example is:
Array( => 290 => 69 => 3 => width="290" height="69" => 8 => image/png )
Return Value Description
* Index 0 gives the image width in pixels.
* Index 1 gives the image height in pixels.
* Index 2 gives the image type. The returned value is a number, where 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.
* Index 3 gives a string with the width and height, which can be used directly in an HTML tag.
* Index bits gives the number of bits for each color in the image, in binary format.
* Index channels gives the number of channels in the image. For RGB images, the default is 3.
* Index mime gives the MIME information of the image. This information can be used to send the correct Content-type header in HTTP, e.g.: header("Content-type: image/jpeg");
[PHP Image Processing](#)
YouTip