For me getImageResolution() always returns X and Y resolution in pixels per centimeter, no matter if I set it with setImageUnits() or not.
So an easy way to convert the result from pixels per centimeter to pixels per inch is to do this:
<?php
$resource = new Imagick($path);
$imageResolution = $resource->getImageResolution();
if (!empty($imageResolution['y'])) {
$imageResolution['y'] =
round($imageResolution['y'] * 2.54, 2);
}
if (!empty($imageResolution['x'])) {
$imageResolution['x'] =
round($imageResolution['x'] * 2.54, 2);
}
?>