Created
September 12, 2014 14:54
-
-
Save feketegy/0cb1488f0320d1fa81d0 to your computer and use it in GitHub Desktop.
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
$png = [ | |
'format' => 'H32', | |
'marker' => '89504e470d0a1a0a0000000d49484452' | |
]; | |
$bytes_to_read = strlen( $png['marker'] ) / 2; | |
$fp = fopen('your-filename.png', 'r'); | |
$data = fread($fp, $bytes_to_read); | |
fclose($fp); | |
$x = unpack( $png['format'], $data); | |
$is_png = ( $x[1] == strtolower( $png['marker'] ) ) ? true : false; | |
var_dump( $is_png ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment