2006.02.07 10:26 "[Tiff] Re: Mega newbie question", by Dermot Paikkos

2006.02.07 11:48 "Re: [Tiff] Re: Mega newbie question", by Joris Van Damme

> TIFFGetField(tiff, 33424, &count, &data);
> printf("Tag %d: %d, count %d0, 33424, *(uint32 *)data, count);
> TIFFGetField(tiff, 36867, &count, &data);
> printf("Tag %d: %s, count %d0, 36867, (char *)data, count);

Is there a missing " mark here?

Yes, indeed.

   int hasPSfield;
  unsigned long imageOffset, result;
  uint16 count;
  void *data;

  TIFF* tif = TIFFOpen("test.tif", "r");
  if (tif == NULL) {
        printf("Failed to open file\n");
   TIFFGetField(tif,TIFFTAG_PHOTOSHOP &hasPSfield);

   if (hasPSfield < 1) {
      printf("No PhotoShop tag found\n");
  TIFFGetField(tif, hasPSfield, &count, &data);
  printf("Tag %d: %d, count %d\n", hasPSfield, *(uint32 *)data,

No, don't use TIFFGetField twice. Do it like this:

TIFF* tif = TIFFOpen("test.tif", "r");
if (tif == NULL)...
if (TIFFGetField(tif,TIFFTAG_PHOTOSHOP,&count,&data)==0)
  printf("No PhotoShop tag found\n");

/* value of Photoshop tag is count bytes long, and its value is loaded into the memory pointed to by data */

TIFFReadDirectory: Warning, test.tif: wrong data type 1 for "XMLPacket"; tag ignored.

TIFFReadDirectory: Warning, test.tif: unknown field with tag 34665 (0x8769) encountered.

Ignore above warnings.

BTW, I just noticed, the situation with the uint16 count is corrected for the Photoshop tag. Declare count as uint32 instead.

I still think the general case should be uint32, instead of uint16, though, but this should not bother you.

Joris Van Damme
Download your free TIFF tag viewer for windows here: