Skip to content

Instantly share code, notes, and snippets.

@jhansche
Created September 19, 2012 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jhansche/3751491 to your computer and use it in GitHub Desktop.
Save jhansche/3751491 to your computer and use it in GitHub Desktop.
getimagesizefromstring() replacement
function getmimetypefromstring($data)
{
// Most image types can be determined in 25 bytes or less.
$data = substr($data, 0, 32);
$uri = 'data://application/octet-stream;base64,' . base64_encode($data);
return exif_imagetype($uri);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment