PHP 8.5.0 Beta 1 available for testing

Voting

: four plus five?
(Example: nine)

The Note You're Voting On

christian at cvj dot se
11 years ago
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);
}

?>

<< Back to user notes page

To Top