Computer >> Computer tutorials >  >> Programming >> PHP

getimagesize() function in PHP


The getimagesize() function is used to display the size of an image.

Syntax

getimagesize(file_name, img_info)

Parameters

  • file_name: The file image i.e. the image path.

  • img_info: Extract some extended information from the image file. Supports only JFIF files.

Return

The getimagesize() function returns an array element with height, width, type, MIME type of the image, etc.

Example

The following is an example:

<?php
   $image_info = getimagesize("https://www.tutorialspoint.com/images/tp-logo-diamond.png");
   print_r($image_info);
?>

Output

The following is the output:

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