TIFF and LibTiff Mail List Archive


1996.11.12 14:21 "Basic TIFF parsing question", by Ben Ko
1996.11.12 11:00 "Re: Basic TIFF parsing question", by Niles Ritter
1996.11.12 17:42 "Re: Basic TIFF parsing question", by Jin Chen
1996.11.13 12:10 "Re: Basic TIFF parsing question", by Ben Ko
1996.11.13 14:18 "Re: Basic TIFF parsing question", by Fredrik Lundh
1996.11.13 18:35 "Re: Basic TIFF parsing question", by Ben Ko

1996.11.12 17:42 "Re: Basic TIFF parsing question", by Jin Chen

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:

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

Dr Jin Chen