getimagesizefromstring

(PHP 5 >= 5.4.0, PHP 7)
Get the size of an image from a string
array getimagesizefromstring ( string $imagedata [, array &$imageinfo ] )

Identical to getimagesize() except that getimagesizefromstring() accepts a string instead of a file name as the first parameter.

See the getimagesize() documentation for details on how this function works.

Parameters:
imagedata

The image data, as a string.

imageinfo

See getimagesize().

Returns:

See getimagesize().

Examples:
getimagesizefromstring() example
1
2
3
4
5
6
7
8
9
10
<?php
$img '/path/to/test.png';
 
// Open as a file
$size_info1 getimagesize($img);
 
// Or open as a string
$data       file_get_contents($img);
$size_info2 = getimagesizefromstring($data);
?>
See also:

getimagesize() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.