PHP | getimagesizefromstring() Function Last Updated : 26 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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: array getimagesizefromstring( $imagedata, &$imageinfo ) Parameters: This function accepts two parameters as mentioned above and described below: $filename: It is a mandatory parameter which accepts image data as a string. $imageinfo: It is an optional parameter which allows to extract some extended information from the image file such as the different JPG APP markers as associative array. Return Value: This function returns the dimensions along with the file type and the height/width text string. Below programs illustrate the getimagesizefromstring() function in PHP: Image: Example 1 : php <?php $img = 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-25.png'; // Open image as a string $data = file_get_contents($img); // getimagesizefromstring function accepts image data as string $info = getimagesizefromstring($data); // Display the image content var_dump($info); ?> Output: array(6) { [0]=> int(667) [1]=> int(184) [2]=> int(3) [3]=> string(24) "width="667" height="184"" ["bits"]=> int(8) ["mime"]=> string(9) "image/png" } Example 2: php <?php $img = 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-25.png'; // Open image as a string $data = file_get_contents($img); // getimagesizefromstring function accepts image data as string list($width, $height, $type, $attr) = getimagesizefromstring($data); // 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.getimagesizefromstring.php Comment More infoAdvertise with us Next Article PHP | getimagesizefromstring() Function S sarthak_ishu11 Follow Improve Article Tags : Technical Scripter Web Technologies PHP Image-Processing PHP-function +1 More Similar Reads PHP | imagecreatefromstring() Function The imagecreatefromstring() function is an inbuilt function in PHP which is used to create a new image from string file or URL. This image can be further worked upon in the program. This function is usually used when you want to edit your images after loading them from a string. Syntax: resource ima 2 min read PHP | getimagesize() Function 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_ 2 min read PHP | imagestring() Function The imagestring() function is an inbuilt function in PHP which is used to draw the string horizontally. This function draws the string at given position. Syntax: bool imagestring( $image, $font, $x, $y, $string, $color ) Parameters: This function accepts six parameters as mentioned above and describ 2 min read 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 | imagestringup() Function The imagestringup() function is an inbuilt function in PHP which is used to draw a string vertically. Syntax: bool imagestringup( $image, $font, $x, $y, $string, $color ) Parameters: This function accepts six parameters as mentioned above and described below: $image: The imagecreatetruecolor() funct 2 min read Like