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:

 Live Demo

<?php
   $image_info = getimagesize("http://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)

Updated on: 31-Dec-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements