Skip to content

Instantly share code, notes, and snippets.

@piotrplenik
Created June 12, 2015 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrplenik/411f0d5b9fdff71552f0 to your computer and use it in GitHub Desktop.
Save piotrplenik/411f0d5b9fdff71552f0 to your computer and use it in GitHub Desktop.
Detect JPEG markers in string - http://en.wikipedia.org/wiki/JPEG
function isJpeg($string) {
if(ord($string[0]) != 0xFF) {
return false;
}
if(ord($string[1]) != 0xD8) {
return false;
}
$count = strlen($string);
if(ord($string[$count-2]) != 0xFF) {
return false;
}
if(ord($string[$count-1]) != 0xD9) {
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment