Skip to content

Instantly share code, notes, and snippets.

@t-cyrill
Created July 30, 2013 01:50
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save t-cyrill/6109550 to your computer and use it in GitHub Desktop.
Save t-cyrill/6109550 to your computer and use it in GitHub Desktop.
Define getimagesizefromstring to use in PHP 5.3
<?php
if (!function_exists('getimagesizefromstring')) {
function getimagesizefromstring($data)
{
$uri = 'data://application/octet-stream;base64,' . base64_encode($data);
return getimagesize($uri);
}
}
@phoenix-mstu
Copy link

great!11

@mpyw
Copy link

mpyw commented Jan 22, 2014

WOW

@AnrietteC
Copy link

Thank you, this works well!

@kwilliams1987
Copy link

Slightly improved to restore the $imageinfo parameter.

if (!function_exists('getimagesizefromstring')) {
    function getimagesizefromstring($data, &$imageinfo = array())
    {
        $uri = 'data://application/octet-stream;base64,' . base64_encode($data);
        return getimagesize($uri, $imageinfo);
    }
}

@argaios
Copy link

argaios commented Aug 27, 2015

thanks!!!

@kaizendeveloper
Copy link

Awesome! It works! Thanks!

@CharlieBrownCharacter
Copy link

Thank you for that <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment