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?


In reply to Re^2: Image::info not working properly for tiff images by ww
in thread Image::info not working properly for tiff images by anusuya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.