From: warmerdam@pobox.com (Frank Warmerdam)
Date: Mon, 17 Nov 2003 11:07:10 -0500
Subject: [Tiff] TIFF, v3.6.0. Fetching "custom" tags
In-Reply-To: <20031117151632.GB19759@ak4719.spb.edu>
References: <6.0.0.22.2.20031116193547.02e96f38@pop.earthlink.net> <20031117151632.GB19759@ak4719.spb.edu>
Message-ID: <3FB8F22E.6030207@pobox.com>

Andrey Kiselev wrote:
> On Sun, Nov 16, 2003 at 07:45:43PM -0500, Chris Losinger wrote:
> 
>>"Custom tags can be set and fetched normally using TIFFSetField() and 
>>TIFFGetField(), and appear pretty much like normal tags to application 
>>code. "
>>        I assume I can get rid of the tags/xtiff stuff and LibTiff will 
>>happily read and store any tags that it finds, even non-core tags, like 
>>34665.
>>        But, it doesn't seem to be working. When reading the TIFF dir, i 
>>get warnings about "unknown field with tag 34665 (0x8769) encountered", and 
>>when i call TIFFGetField, nothing is returned. It looks like v3.6.0. is 
>>behaving pretty much exactly like 3.5.7: complain about strange tags, then 
>>ignore them. But that's not what the documentation says is supposed to 
>>happen.
> 
> 
> You should register all extended tags before you can work with them. See
> a sample code attached.

Andrey,

The intent is that new tags encountered should auto-register themselves.
I checked with photometric.tif, and sure enough TIFFGetField() didn't work.
I looked into the code, and it seems that in tif_dirinfo.c 1.21 the line
dp->tdir_tag = IGNORE was added in causing the newly defined tag to be
ignored.  This is something that I had removed in rev 1.17.  Why was
it re-introduced.  Even in 1.17 I wasn't clear on why the code had ever
been there, so perhaps there is a reason you added it?

With that line removed, the fetching of the new tag works fine.  In fact
it is even reported by tiffinfo (named "Tag 34665"):

warmerda@gdal2200[17]% tiffinfo photoshop.tif
TIFFReadDirectory: Warning, photoshop.tif: wrong data type 1 for "XMLPacket"; ta
g ignored.
TIFFReadDirectory: Warning, photoshop.tif: unknown field with tag 34665 (0x8769)
  encountered.
TIFF Directory at offset 0x8
   Subfile Type: (0 = 0x0)
   Image Width: 600 Image Length: 450
   Resolution: 300, 300 pixels/inch
   Bits/Sample: 8
   Compression Scheme: LZW
   Photometric Interpretation: RGB color
   Date & Time: "2003:07:24 11:31:44"
   Image Description: "          "
   Make: "NIKON"
   Model: "E990"
   Samples/Pixel: 3
   Rows/Strip: 4
   Planar Configuration: single image plane
   Photoshop Data: <present>, 6162 bytes
   RichTIFFIPTC Data: <present>, 6 bytes
   Software: Adobe Photoshop 7.0
   Tag 34665: 695892
   Predictor: horizontal differencing 2 (0x2)

I haven't committed the change to tif_dirinfo.c yet, pending feedback on
why the IGNORE setting was there.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



