English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The getimagesize() function is used to obtain image size and related information. It returns an array on success and FALSE on failure, generating an E_WARNING level error message.
Syntax format:
array getimagesize ( string $filename [, array &$imageinfo ] )
The getimagesize() function determines any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2JPX, JB2The size of the JPC, XBM, or WBMP image file is determined and the image dimensions, file type, and height and width of the image are returned.
<?php list($width, $height, $type, $attr) = getimagesize("w3codebox-logo.png"); echo "Width: " . $width; echo "Height: " . $height; echo "Type: " . $attr; ?>
The following example output results are:
Width:290 Height:69 Type:3 Attributes: width="290" height="69"
<?php $remote_png_url = 'http://www.oldtoolbag.com/wp-content/themes/oldtoolbag.com/assets/img/logo-domain-green2.png'; $img_data = getimagesize($remote_png_url); print_r($img_data ); ?>
The following example output results are:
Array ( [0] => 290 [1] => 69 [2] => 3 [3] => width="290" height="69" [bits] => 8 [mime] => image/png )
Return result explanation