I\'m building a Web application that will handle image files that will ultimately be printed, large format.
As part of this, I need to get (i.e. read) and set (i.e.
This is my work solution at Joox.io
/**
* @param $filename
* @return array
*/
function getImageDPI($filename)
{
$resolutions = null;
if (class_exists('Imagick')) {
$image = new Imagick($filename);
$resolutions = $image->getImageResolution();
} else {
$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);
$resolutions = array('x' => hexdec($x), 'y' => hexdec($y));
}
return $resolutions;
}