PHP | getimagesize() Function Last Updated : 01 Aug, 2021 Comments Improve Suggest changes Like Article Like Report The getimagesize() function in PHP is an inbuilt function which is used to get the size of an image. This function accepts the filename as a parameter and determines the image size and returns the dimensions with the file type and height/width of image. Syntax: array getimagesize( $filename, $image_info ) Parameters: This function accepts two parameters as mentioned above and described below: $filename: It is a mandatory parameter which specifies the image file name. $image_info: It is an optional parameter which allows you to extract some extended information from the image file such as the different JPG APP markers as associative array. Return Value: It returns the dimensions along with the file type and a height/width text string. Exceptions: The getimagesize() function returns zero for width and height if the formats which may contain no image or multiple images. The imageinfo parameter only supports JFIF files. The getimagesize() function will generate an error of level E_WARNING, if accessing the filename image is impossible. The getimagesize() will generate an error of level E_NOTICE, if there is any error in reading. Below programs illustrate the getimagesize() function in PHP: Note: The image (geeks.png) given below used in the following program. Program 1: php <?php // Calling getimagesize() function $image_info = getimagesize("geeks.png"); print_r($image_info); ?> Output: Array ( [0] => 667 [1] => 184 [2] => 3 [3] => width="667" height="184" [bits] => 8 [mime] => image/png ) Program 2: php <?php // Calling getimagesize() function list($width, $height, $type, $attr) = getimagesize("geeks.png"); // Displaying dimensions of the image echo "Width of image : " . $width . "<br>"; echo "Height of image : " . $height . "<br>"; echo "Image type :" . $type . "<br>"; echo "Image attribute :" .$attr; ?> Output: Width of image : 667 Height of image : 184 Image type :3 Image attribute :width="667" height="184" Reference: http://php.net/manual/en/function.getimagesize.php PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples. Comment More infoAdvertise with us Next Article PHP | getimagesize() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP | Imagick getImageSize() Function The Imagick::getImageSize() function is an inbuilt function in PHP which is used to get the image length in bytes. Syntax: int Imagick::getImageSize( void ) Parameters: This function doesnât accepts any parameter. Return Value: This function returns an integer value containing the current image size 1 min read PHP | imagesx() Function The imagesx() function is an inbuilt function in PHP which is used to return the width of the given image. Syntax: int imagesx( $image ) Parameters: This function accepts single parameters $image which is mandatory. This $image variable can store the image created by imagecreatetruecolor() image cre 1 min read PHP | imagesy() Function The imagesy() function is an inbuilt function in PHP which is used to return the height of the given image. Syntax: int imagesy( $image ) Parameters: This function accepts single parameters $image which is mandatory. This $image variable store the image created by imagecreatetruecolor() image creati 1 min read PHP | imagesettile() Function The imagesettile() function is an inbuilt function in PHP which is used to set the tile image for filling the area. Syntax: bool imagesettile( $image, $tile ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It is returned by one of the image creation 2 min read PHP | getimagesizefromstring() Function The getimagesizefromstring() function is an inbuilt function in PHP which is used to get the size of an image from a string. This function accepts the image data as a string parameter and determines the image size and returns the dimensions with the file type and height/width of the image. Syntax: a 2 min read Like