Created
June 12, 2015 08:54
-
-
Save piotrplenik/411f0d5b9fdff71552f0 to your computer and use it in GitHub Desktop.
Detect JPEG markers in string - http://en.wikipedia.org/wiki/JPEG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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