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

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

On 6 Feb 2006 at 18:41, Joris wrote:

> Dermot Paikkos wrote:
> > I have been reading the docs at awaresystems.com on accessing the
> > PhotoShop thumbnails within a tiff file.
>

> That's .be, man... http://www.awaresystems.be/. Not all that glitters, > is .com.

Ouch, should have spotted a Belgium domain.

> > > Does that mean that the length of the block is 10124416 bytes? Or
is
> > this just it's unique identifier?
>
> See section 'AUTOREGISTERED TAGS' on
> http://www.remotesensing.org/libtiff/man/TIFFGetField.3tiff.html.
>
> <quote>
>
> 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?

> </quote>
>

> I'm not too sure why count is declared uint16 here... It should be > uint32 if you ask me. Plenty of tags have potentially over 64K of data,

> and in any case, the count in tags in actual file normal TIFF (not > BigTIFF) is unsigned 32bit. I'm also unsure why datatype is not

> returned by this interface... I think it should be if it is to be used > in a robust manner. Otherwise, if the calling code supposes LONG

> datatype, but the actual (possibly invalid) file states BYTE datatype, > calling code is next going to boom in an access violation when

> accessing past 1/4 of what is supposes is actual data.

I can't say I am not entirely sure what is going on with the above code. I looks like it uses stdarg.h to decipher the data-types...but somehow it isn't being complete.

Does this mean count is the length of the PS field?

========= test1.c ===========
  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");
        exit(8);
  }
   TIFFGetField(tif,TIFFTAG_PHOTOSHOP &hasPSfield);

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

/* TIFFGetField(tif, hasPSfield, &count, &data);
  printf("Tag %d: %s, count %d\n", hasPSfield, (char *)data, count);
*/
  printf("Value of GetField = %d\n", hasPSfield );

  TIFFClose(tif);
  return 0;

============================

returns:

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

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

Tag 10124416: 11328828, count 2052
Value of GetField = 10124416

I am still unclear where I should start to loop from (value of m in pseudo-code).

> Good luck. Don't be shy to post your results, I would welcome any good > actual code contribution to the Photoshop tag page.

Not sure I can produce any 'good code' as yet but I'll always put what I have up for examination.

Thanx for the help.
Dp.