Around my image processing software, I use exiftool to successfully drag and drop exif information from Cr2, TIFF, JPG files. Added tags, such as "keywords," are all visible in the OSX (Mountain Lion) Finder, Preview, and Spotlight are beautifully indexed.
For PNG, I need to fall back to XMP, as it is a metadata container for PNG. However, tags added to exiftool do not seem to be accepted by either Preview or SpotLight. In contrast, if I first add a tag to Preview and use exiftool to add a new tag later, this is indexed by IS. The difference here I see here is the raw XMP data, where exiftool re-creates the header, and Preview does not.
As an example, consider the following PNG from a Wikipedia page in PNG without metadata https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png :

Adding a keyword using exiftool and then resetting the XMP data block:
exiftool -xmp-dc:subject=ViaExifSubject ./PNG_transparency_demonstration_1.png exiftool -xmp -b ./PNG_transparency_demonstration_1.png
Gives the following XMP data:
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?> <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 9.02'> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1/'> <dc:subject> <rdf:Bag> <rdf:li>ViaExifSubject</rdf:li> </rdf:Bag> </dc:subject> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end='r'?>
However, the ViaExifSubject was not found in the Preview or Finder details pane.
Alternatively, use the OSX preview to add comments (Click the Preview, Show Inspector, Go To Keywords tab, click + to add a keyword). XMP is reset again through exiftool:
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.1.2"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:subject> <rdf:Bag> <rdf:li>viaPreview</rdf:li> </rdf:Bag> </dc:subject> </rdf:Description> </rdf:RDF> </x:xmpmeta>
The xpacket header xpacket not in the preview of the generated keyword, but the XMP Toolkit is different. Now the "throughPreview" tag is displayed, for example. using mdls in the CLI.
Pressing raw XMP information into a clean file also does not produce the expected result:
exiftool "-xmp<=viaexif.xmp" PNG_transparency_demonstration_1.png
Surprisingly, if I first create a tag using Preview, and THEN executes the above command, the new tags will be reflected. I suspect that I am observing an external data analyzer that needs to be “activated”, picks up tags and puts them in another store (for example, .DS_store). I have not seen the addition of xattr.
These are my questions:
- Is exiftool the right tool for XMP / PNG combination and I am missing a specific function.
- Is OSX a violation of the XMP standard? Edit: apparently XMP is not respected by OSX by default
- Should I research an alternative container layout tool?
I dug up my xmp_sdk on my disk and experimented with the provided samples:
ModifyXMP can write pure XMP information to PNG, which is shown in OSX Finder - this is a good target.
ReadXMP can read XMP information inserted by ExifTool in PNG, although this information is not displayed in OSX Finder.
The file size is similar when viewing ModifyXMP and exiftool output, inserting the same XMP block. The difference shows that exiftool appends to the end of the file, where XMP sdk places it in the PNG header. The XMP specification states that "encoders are encouraged to place a fragment at the beginning of a file, but this is not required."
Conclusion: There is a (slight) difference in how Exiftool writes XMP, and this is especially useless with extracting OSX metadata.
Till:
- Experiment with the XMP SDK instead to insert a clean XMP packet at the beginning, and exiftool will reuse this first snippet.
I was posted to the exiftools forum , and author Phil Harvey replied:
I played a little with Apple Preview, and it not only does not recognize XMP at the end of the file, but also deletes this XMP when adding keywords to the image. I assume that Apple software ignores XMP if it arrives after the IDAT block. It would be great if the XMP specification indicated that the XMP fragment arrives before the IDAT, but this did not happen, so this should be considered a bug in Apple software. I added this to the List of Known Issues list .
Finally, Phil Harvey decided to solve this problem on his own in Exiftool:
I did a lot of work on this, and Exiftool 9.40 will have a new opportunity to allow you to write XMP before the PNG IDAT block. The corresponding command will look like this: exiftool -api PNGEarlyXMP ...
Apple filed a bug - upgrade to 2014: Apple closed my bug by stating that they would not take any action in this section