Skip to content

Instantly share code, notes, and snippets.

@atomize
Created February 11, 2013 14:14
Show Gist options
  • Save atomize/4754628 to your computer and use it in GitHub Desktop.
Save atomize/4754628 to your computer and use it in GitHub Desktop.
Get image DPI in flat PHP
function get_dpi($filename){
$a = fopen($filename,'r');
$string = fread($a,20);
fclose($a);
$data = bin2hex(substr($string,14,4));
$x = substr($data,0,4);
$y = substr($data,0,4);
return array(hexdec($x),hexdec($y));
}
@atomize
Copy link
Author

atomize commented Feb 14, 2013

this behaves weird, just a note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment