Easy Tutorial
❮ Func Misc Constant Func Date Strftime ❯

PHP getimagesizefromstring - Image Information Retrieval Function

PHP Image Processing

getimagesizefromstring — Retrieves image size information from a string.

Syntax

array getimagesizefromstring ( string $imagedata [, array &$imageinfo ] )

Similar to the getimagesize() function. The difference is that getimagesizefromstring() takes the image data as a string representation in the first parameter, rather than a filename.

Parameters

Example

<?php
$img = 'tutorialpro-logo.png';

// Open as a file
$size_info1 = getimagesize($img);

// Open as a string
$data = file_get_contents($img);
$size_info2 = getimagesizefromstring($data);
print_r($size_info2);
?>

The output of the above example is:

Array
(
    [0] => 290
    [1] => 69
    [2] => 3
    [3] => width="290" height="69"
    [bits] => 8
    [mime] => image/png
)

PHP Image Processing

❮ Func Misc Constant Func Date Strftime ❯