Easy Tutorial
❮ Pdo Commit Func String Crypt ❯

PHP getimagesize Function - Get Image Information

PHP Image Processing

The getimagesize() function is used to retrieve the size of an image and related information. It returns an array on success, or FALSE and generates an E_WARNING level error message on failure.

Syntax:

array getimagesize ( string $filename [, array &$imageinfo ] )

The getimagesize() function determines the size of any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM, or WBMP image file and returns the dimensions, file type, and image height and width.

Example 1: Local Image File

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

Output:

Width: 290
Height: 69
Type: 3
Attributes: width="290" height="69"

Example 2: Remote Image File

<?php
$remote_png_url = 'http://www.tutorialpro.org/wp-content/themes/w3cschool.cc/assets/img/logo-domain-green2.png';
$img_data = getimagesize($remote_png_url);
print_r($img_data);
?>

Output:

Array
(
    [0] => 290
    [1] => 69
    [2] => 3
    [3] => width="290" height="69"
    [bits] => 8
    [mime] => image/png
)

Return Result Explanation:

PHP Image Processing

❮ Pdo Commit Func String Crypt ❯