Mailinglist Archives:
Infrared
Panorama
Photo-3D
Tech-3D
Sell-3D
MF3D

Notice
This mailinglist archive is frozen since May 2001, i.e. it will stay online but will not be updated.
<-- Date Index --> <-- Thread Index --> [Author Index]

P3D Re: How to query image dimensions programmatically?


  • From: "Greg Wageman" <gjw@xxxxxxxxxx>
  • Subject: P3D Re: How to query image dimensions programmatically?
  • Date: Sun, 15 Nov 1998 15:10:18 -0800


From: marble <marble@xxxxxxxxxxx>


>    is there some way to query an image file to find out its
dimensions?
>if i knew its real height & width, i could get a ratio, and then derive
the
>new width based on my constant height.


If you have access to the "pnm" package (Portable Pixmap/Portable
Greymap/Portable Anymap), you can use the "pnmfile" utility to get back
such information about most common image formats by piping the output of
the appropriate converter.  E.g. on a Unix box,

    giftopnm image.gif | pnmfile

would return the dimensions and bit depth of the resulting anymap.  If
you are using Perl to write your cgi scripts, it would be a piece of
cake to parse the output and capture the dimension information.

Alternatively, the Independent JPEG Group's (IJG) "djpeg" utility could
be hacked to produce a program to give you this information for a JPEG,
and the PNM package's GIF reader could be hacked for GIF images, etc.

The PNM package has been ported to many different operating systems
besides Unix.

     -Greg W. (gjw@xxxxxxxxxx)



------------------------------