Received: from sgi.sgi.com (192.48.153.1) by cerious.com
 with SMTP (Apple Internet Mail Server 1.1.1); Tue, 12 Nov 1996 18:39:02 -0500
Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by sgi.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id MAA28845; Tue, 12 Nov 1996 12:24:05 -0800
Received: (from daemon@localhost) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) id SAA09341 for tiff-list; Tue, 12 Nov 1996 18:10:54 GMT
Received: from sgi.sgi.com (sgi.engr.sgi.com [192.26.80.37]) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) via ESMTP id KAA09336 for <tiff-relay@relay.engr.sgi.com>; Tue, 12 Nov 1996 10:10:53 -0800
Received: from netmail.city.ac.uk (netmail.city.ac.uk [138.40.12.1]) by sgi.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id KAA23736 for <tiff@sgi.com>; Tue, 12 Nov 1996 10:03:47 -0800
Received: from cepc68 (cepc68.city.ac.uk [138.40.47.25]) 
	  by netmail.city.ac.uk (/City/2.1) with SMTP id RAA01055; Tue, 12 Nov 1996 17:41:42 GMT
Message-Id: <2.2.32.19961112174225.008eed74@pophost.city.ac.uk>
X-Sender: sd316@pophost.city.ac.uk
X-Mailer: Windows Eudora Pro Version 2.2 (32)
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Tue, 12 Nov 1996 17:42:25 +0000
To: bko@netcom.com (Ben Ko)
From: Jin Chen <J.Chen@city.ac.uk>
Subject: Re: Basic TIFF parsing question
Cc: tiff@sgi.com
Sender: owner-tiff@relay.engr.SGI.COM
Precedence: bulk
Status: R

At 06:21 12/11/96 -0800, you wrote:
>This question is WAY basic but I'm not sure where else to ask.
>
>I would like to parse a TIFF file for the following info:
>
>- resolution
>- image dimensions (w x h)
>- color mode (e.g., grayscale, bilevel)
>
>I'm not going to modify the image data in anyway. I just want to find out
>what's in there.
>
>I've DLed the TIFF spec from the Adobe site but am not able to figure out
>how to do this from the spec information. Can anyone point me to a more
>beginner-type step-by-step reference (book, article, FAQ, earlei posting)
>for parsing the information in a TIFF?
>
>I'll be using MacPerl to do this. I've successfully used MacPerl to parse an
>EPS but the TIFF spec has me totally confused. This has probably less to do
>with the TIFF spec and more to do with my not being a professional programmer.
>
>Based on the TIFF spec, it seems there are various ways to write out a TIFF.
>Does this mean that a TIFF saved from Photoshop vs. a TIFF generated from a
>UNIX-based OPI system will have different enough formats that the parsing
>routine would need to handle both? or are is the info I"m looking for basic
>enough that it should be stored the same either way?

Try this code:

#include "tiffio.h"
...

/* definitaions */
TIFF* tif ;
uint32 w, h, x, y, bits;

/* Open tiff file */
tif = TIFFOpen("TiffImageFile.tif", "ru");
			 
if (!tif) {
	return ;
	}
/* Retrieve information */

TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);         /* image width in pixels */
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);        /* image width in pixels */
TIFFGetField(tif, TIFFTAG_XRESOLUTION, &x);        /* pixels/resolution in x */
TIFFGetField(tif, TIFFTAG_YRESOLUTION, &y);        /* pixels/resolution in y */
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits);   /* bits per channel
(sample)*/
TIFFClose(tif);
...

_________________________________________________________________________
Dr Jin Chen                                             J.Chen@city.ac.uk

