If you want it without Imagick or GD Library
.
I was struggling with this, and since I found it, here you go.
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,4,4);
return array(hexdec($x),hexdec($y));
}
and then print the array or do with it what you want.