1 (edited by dgossage 2014-01-06 20:05:16)

Topic: php-pecl-imagick getImageResolution returns 0's

Not sure at what update this started occurring, or if it is in the php rpm or ImageMagick-last-libs but when using getImageResolution on an image instead of getting back the parameters expected we get 0's returned.

Centos6.5
ImageMagick-last-libs-6.8.7.4-1.el6.remi.x86_64
php-pecl-imagick-3.1.2-2.el6.remi.5.4.x86_64

<?php

$path="/path_to_image";
$img= new imagick($path);
print "Geometry    ";
print_r($img->getImageGeometry());
print "Resolution   ";
print_r($img->getImageResolution());
?>


Geometry    Array
(
    [width] => 320
    [height] => 480
)
Resolution   Array
(
    [x] => 0
    [y] => 0
)

If I remove php-pecl-imagick and install ImageMagick-devel from centos repo then install imagick from pecl i get expected behavior.
ImageMagick-devel-6.5.4.7-6.el6_2.x86_64

Geometry    Array
(
    [width] => 240
    [height] => 170
)
Resolution   Array
(
    [x] => 28.35
    [y] => 28.35
)

Re: php-pecl-imagick getImageResolution returns 0's

Can you check exif data of the image ?

$ rpm -q ImageMagick-last php-pecl-imagick
ImageMagick-last-6.8.7.4-1.el6.remi.x86_64
php-pecl-imagick-3.1.2-2.el6.remi.5.5.x86_64

$ exiftool /tmp/menhirs.jpg  | grep Resol
X Resolution                    : 180
Y Resolution                    : 180

$ php /tmp/foo.php /tmp/menhirs.jpg 
Geometry    Array
(
    [width] => 1280
    [height] => 431
)
Resolution   Array
(
    [x] => 180
    [y] => 180
)

P.S.1: same result with PHP 5.4 and php-pecl-imagick-3.1.2-2.el6.remi.5.4.x86_64
P.S.2: same result with php-pecl-imagick-3.2.0-0.2.RC1.fc19.remi.5.5.x86_64

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: php-pecl-imagick getImageResolution returns 0's

You may be right as the ones that fail don't have any exif data it seems.  I had been testing using the ImageMagic identify -verbose method and regardless of exif data being in file it did have the resolution that way.

  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 320x480+0+0
  Resolution: 72x72

Has it always been that imagick uses exif data to grab that?  It could just be coincidence that we had a large string of images sent with no exif data that happened to be around time of rpm update.

Re: php-pecl-imagick getImageResolution returns 0's

Good

Re: php-pecl-imagick getImageResolution returns 0's

If I remove php-pecl-imagick and install ImageMagick-devel from centos repo then install imagick from pecl i get expected behavior.

___________
Nawaz