2004.10.03 22:45 "Re: [Tiff] IPTC tags", by Bob Friesenhahn
I'm trying to work out how to read and write IPTC tags into TIFF images. I've downloaded the specification for IIMv4 from http://www.iptc.org/download/download.php?fn=IIMV4.1.pdf and I think that's fairly clear how an IPTC record is structured.
But... How does this relate to the libtiff Tag Reference guide at http://www.awaresystems.be/imaging/tiff/tifftags.html?? Is there a private tag description for the IPTC information or is it held inside the Photoshop Tag (ref 34377)?
The tag for IPTC is TIFFTAG_RICHTIFFIPTC. Note that the length of this tag is the length in 32-bit words so you must multiply by four to obtain bytes.
To obtain the tag:
TIFFGetField(tiff,TIFFTAG_RICHTIFFIPTC,&length,&value);
length *= 4; // bytes
To save the tag (length in bytes):
TIFFSetField(tiff,TIFFTAG_RICHTIFFIPTC,(uint32) length/4,(void *) value);
There is also the issue that the content may be byte-swapped (due to being written on a different-endian CPU) so you would need to do:
if (TIFFIsByteSwapped(tiff))
TIFFSwabArrayOfLong((uint32 *) value,length/4);
Yes, the Photoshop profile will also contain an IPTC tag. That makes life more interesting. :-)
If there is no TIFFTAG_RICHTIFFIPTC tag but there is a TIFFTAG_PHOTOSHOP then a IPTC tag can still be obtained.
Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us
http://www.simplesystems.org/users/bfriesen