in reply to Image::info not working properly for tiff images

Which version? Try upgrading. What does imagemagick identify return?

It seems to work for me

$ pmvers Image::Info 1.29 $ perl -MImage::Info=image_info -MDDS -e ' Dump( image_info (shift) )' + untitled.tif $HASH1 = { BitsPerSample => [ ( 8 ) x 3 ], Compression => 'LZW', file_ext => 'tif', file_media_type => 'image/tiff', height => 435, NewSubfileType => '', PhotometricInterpretation => 'RGB', PlanarConfiguration => 'Chunky', ResolutionUnit => 'dpi', RowsPerStrip => 7, SamplesPerPixel => 3, StripByteCounts => [ ( 178 ) x 7, 186, 209, ( 205 ) x 2, 212, ( 220 ) x 4, 216, 218, 220, 219, 218, 219, 224, 234, 243, 245, 251, 247, 249, 220, ( 218 ) x 5, 220, 223, 228, 186, ( 178 ) x 23, 69 ], StripOffsets => [ 8, 186, 364, 542, 720, 898, 1076, 1254, 1440, 1649, 1854, 2059, 2271, 2491, 2711, 2931, 3151, 3367, 3585, 3805, 4024, 4242, 4461, 4685, 4919, 5162, 5407, 5658, 5905, 6154, 6374, 6592, 6810, 7028, 7246, 7464, 7684, 7907, 8135, 8321, 8499, 8677, 8855, 9033, 9211, 9389, 9567, 9745, 9923, 10101, 10279, 10457, 10635, 10813, 10991, 11169, 11347, 11525, 11703, 11881, 12059, 12237, 12415 ], "Tag-0x013d" => 1, width => 581, XResolution => '', YResolution => '' }; $ identify untitled.tif untitled.tif TIFF 581x435 581x435+0+0 8-bit DirectClass 12.9kb

Replies are listed 'Best First'.
Re^2: Image::info not working properly for tiff images
by ww (Archbishop) on Sep 18, 2009 at 12:43 UTC

    But OP is seeking "resolution" rather than width and height. See AM's output lines 123 & 124;

    From perldoc Image::Info ( http://search.cpan.org/~gaas/Image-Info-1.16/lib/Image/Info.pm ).

    resolution
        The value of this field normally gives the physical size of the
        image on screen or paper. When the unit specifier is missing then
        this field denotes the squareness of pixels in the image.
    
        The syntax of this field is:
    
           <res> <unit>
           <xres> "/" <yres> <unit>
           <xres> "/" <yres>
    
        The <res>, <xres> and <yres> fields are numbers. The <unit> is a
        string like "dpi", "dpm" or "dpcm" (denoting "dots per
        inch/cm/meter).

    Update (at approx +12h after the above): I've tried numerous variants on OPs code (and that offered by the doc) with both .jpg and .tif. At least under W2k, those reproduced OP's problem -- to wit, that the package fails to return resolution for a tif.

    One snippet:

    my $res = $info->{resolution }; # NG for .tif and this doesn't work either {resolution res dpi } print "\t $res\n"; #line 23 # Use of uninitialized value in concatenation (.) or string at pl_ +test\796079.pl line 23.

    Feed the script above this excerpt from an array of .tif and .jpg files, and it behaves for .jpg but not for .tif.

    Also observed: the data extracted via:

    my $info = image_info($img); if (my $error = $info->{error}) { die "Can't open image file: $error\n"; } print Dumper $info;

    provides the expected info except for showing blank fields for 'YResolution' => '', and for 'XResolution' => '', when fed a .tif but provides values which match information (extracted by other means) from a .jpg.

    Bug? or just /me in over my head?