PHP Getimagesizefromstring () function

PHP

Syntax:
array getimagesizefromstring ($imagedata, & amp; $imageinfo)
Parameters: this function takes two parameters as above and described below:
  • $filename:this is a required parameter that accepts image data as a string.
  • $imageinfo:this is an optional parameter that allows you to extract some extended information from the image file, such as various JPG APP markers, as an associative array.
Return Value:This function returns the dimensions along with the file type and the height / width text string.The following programs illustrate the getimagesizefromstring() functionin PHP :Image: Note p 1: $img = ' https://media.engineerforengineer. org / wp-content / uploads / engineerforengineer-25.png ' ;  
// Open image as string $data = file_get_contents ( $img );  
// getimagesizefromstring function accepts image data as a string $info = getimagesizefromstring ( $data );  
// Show 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: $img = ' https://media.engineerforengineer. org / wp-content / uploads / engineerforengineer-25.png ' ;  
// Open image as string $data = file_get_contents ( $img );  
// getimagesizefromstring function accepts image data as a string list ( $width , $height , $type , $attr ) = getimagesizefromstring ( $data );  
// Display image dimensions 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"
Link: http://php.net/manual/en/function.getimagesizefromstring.php



Get Solution for free from DataCamp guru