Skip to content

Instantly share code, notes, and snippets.

@sursir
Last active June 6, 2018 07:49
Show Gist options
  • Select an option

  • Save sursir/44e8dbda7e9cfc58e78c72b07195f3ce to your computer and use it in GitHub Desktop.

Select an option

Save sursir/44e8dbda7e9cfc58e78c72b07195f3ce to your computer and use it in GitHub Desktop.
php getimagesize stream file schema getimagesizefromstring
<?php
$imageStream = file_get_content('..') or curl_get_content('..');
if ($info = @getimagesize('data://application/octet-stream;base64,' . base64_encode(imageStream))) {
var_dump($info);
if (isset($info['mime']) && substr($info['mime'], 0, 6) == 'image/') {
$suffix = substr($info['mime'], 6);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment