| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread1996.11.12 17:42 "Re: Basic TIFF parsing question", by Jin ChenAt 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
|
|||||||