Exiftool to create OSX visible XMP metadata in PNG images

gdh

Around my image processing software I use exiftool to successfully shuffle around exif info from Cr2, TIFF, JPG files. The added tags, such as "keywords", are all visible in OSX (mountain lion) Finder, Preview and nicely indexed by Spotlight.

For PNGs I need to fallback to XMP as this is the metadata container for PNG. However, exiftool-added tags do not seem to be picked up by neither Preview nor SpotLight. In contrast, if I first add a tag in Preview and use exiftool to add a new tag later, this IS indexed. The difference here I see here in the XMP raw data, where exiftool newly creates a header, while Preview does not.

As an example, look at the following PNG from the Wikipedia page on PNG without metadata https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png:

Sample PNG without metadata

Adding a keyword using exiftool, and afterwards dumping the XMP datablock:

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, in Preview or Finder info panel, no "ViaExifSubject" is found.

Alternatively, using OSX Preview to add comments (Open in Preview, Show Inspector, Go to Keywords tab, click '+' to add keyword). XMP dumped again via 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 is not present in Preview generated keyword, and the XMP Toolkit is different. The "viaPreview" tag is visible now, e.g. using mdls on the CLI.

Pushing raw XMP info into a clean file also doesn't give the expected result:

exiftool "-xmp<=viaexif.xmp" PNG_transparency_demonstration_1.png

Surprisingly, if I first create a tag using Preview and THEN do the command above, the new tags are reflected I suspect that I am overseeing an external data parser that needs to be 'activated', picks up the tags and puts them in a different store (e.g. .DS_store). I have not seen any xattr being added.

These are my questions:

  • Is exiftool the right tool for XMP/PNG combination, and am I missing a specific feature
  • Is OSX defying an XMP standard? Edit: apparently XMP is not respected by OSX per default
  • Should I investigate in an alternative tool to strip the container ?

I dug up my xmp_sdk on my disk and experimented with the provided samples:

ModifyXMP can write "pure" XMP info into PNG which is shown in OSX Finder -- this is a good target.

ReadingXMP can read XMP info inserted by ExifTool into PNG, although this info is not shown in OSX Finder.

The file size is similar when looking at ModifyXMP's output and exiftool inserting the exact same XMP blob. A diff shows that exiftool appends at the end of the file where XMP sdk puts it in the header of the PNG. The XMP spec states that "Encoders are encouraged to place the chunk at the beginning of the file, but this is not required."

Conclusion: There is a (slight) difference in how exiftool writes XMP and this specifically messes with OSXs metadata retrieval.

For now:

  • Experiment with XMP SDK instead to insert a clean XMP packet at the beginning, and have exiftool reuse this first chunk.
  • I reposted on exiftools' forum, and author Phil Harvey replied:

    I did some playing with Apple Preview, and not only does it not recognize XMP at the end of the file, but also it deletes this XMP when adding keywords to the image. My guess is that Apple software ignores XMP if it comes after the IDAT chunk. It would have been wonderful if the XMP specification had mandated that the XMP chunk come before IDAT, but it didn't, so this must be considered a bug in the Apple software. I have added this to the list of Known problems.

    Finally, Phil Harvey decided to fix this problem in Exiftool itself:

    I have done a lot of work on this, and Exiftool 9.40 will have a new option to allow you to write XMP before the PNG IDAT chunk. The corresponding command will look like this: exiftool -api PNGEarlyXMP ...

  • Filed a bug at Apple -- Update dec 2014: Apple closed my bug stating that they will not take any action on this topic

indersr
  1. You try XMP Toolkit SDK and its samples and write metadata for PNG.
  2. OSX uses IPTC (not sure, read somewhere) and XMP toolkit does reconcile XMP and IPTC, therefore the keyword added using XMP Toolkit will be searchable on OS X.

From your observation it looks like exiftool doesn't reconcile IPTC and XMP. What you could try is to try and change both IPTC and XMP inside PNG and see if it is searchable.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is XMP metadata supported in PNG images?

From Dev

How can I embed metadata into a custom XMP field with exiftool?

From Dev

Metadata extraction from PNG images

From Dev

Metadata extraction from PNG images

From Dev

Is it possible to create a custom namespace tag in XMP Dublin core metadata?

From Dev

Read metadata with ExifTool

From Dev

Read metadata with ExifTool

From Dev

Unable to access config'd custom xmp namespace in exiftool

From Dev

iText -> Best approach to read XMP metadata?

From Dev

Create animated gif from a set of png images

From Dev

create a video file from series of png images

From Dev

How to prevent recovering metadata when using ExifTool?

From Dev

Does OSX preview tool tag images with any kind of metadata or anything to identify the computer?

From Dev

JPEG and PNG metadata compression

From Dev

How to read/write xmp metadata in c# or c++

From Dev

Write PDF metadata from the file name using Exiftool or PDFtk

From Dev

Is there a way to get Exiftool to recursively scan the metadata of files embedded within files?

From Dev

Add part of filename as PDF metadata using bash script and exiftool

From Dev

PHP GD - How do I create a new png image from 3 png images in layers in order

From Dev

PHP GD - How do I create a new png image from 3 png images in layers in order

From Dev

PNG images not loaded

From Dev

PHP dynamic png images

From Dev

Webpack not loading png images

From Dev

.png Images will not display on webpage

From Dev

convert all images to PNG

From Dev

PHP dynamic png images

From Dev

Images not visible when opened with jar. After upgrading javaFx to create new image requires the full directory

From Dev

Python XMP Toolkit is too strict ("Unrecognized TIFF prefix") when trying to read image metadata

From Dev

Writing XMP Metadata in jpeg (with PHP) - Using Single or Multiple rdf:Description blocks

Related Related

  1. 1

    Is XMP metadata supported in PNG images?

  2. 2

    How can I embed metadata into a custom XMP field with exiftool?

  3. 3

    Metadata extraction from PNG images

  4. 4

    Metadata extraction from PNG images

  5. 5

    Is it possible to create a custom namespace tag in XMP Dublin core metadata?

  6. 6

    Read metadata with ExifTool

  7. 7

    Read metadata with ExifTool

  8. 8

    Unable to access config'd custom xmp namespace in exiftool

  9. 9

    iText -> Best approach to read XMP metadata?

  10. 10

    Create animated gif from a set of png images

  11. 11

    create a video file from series of png images

  12. 12

    How to prevent recovering metadata when using ExifTool?

  13. 13

    Does OSX preview tool tag images with any kind of metadata or anything to identify the computer?

  14. 14

    JPEG and PNG metadata compression

  15. 15

    How to read/write xmp metadata in c# or c++

  16. 16

    Write PDF metadata from the file name using Exiftool or PDFtk

  17. 17

    Is there a way to get Exiftool to recursively scan the metadata of files embedded within files?

  18. 18

    Add part of filename as PDF metadata using bash script and exiftool

  19. 19

    PHP GD - How do I create a new png image from 3 png images in layers in order

  20. 20

    PHP GD - How do I create a new png image from 3 png images in layers in order

  21. 21

    PNG images not loaded

  22. 22

    PHP dynamic png images

  23. 23

    Webpack not loading png images

  24. 24

    .png Images will not display on webpage

  25. 25

    convert all images to PNG

  26. 26

    PHP dynamic png images

  27. 27

    Images not visible when opened with jar. After upgrading javaFx to create new image requires the full directory

  28. 28

    Python XMP Toolkit is too strict ("Unrecognized TIFF prefix") when trying to read image metadata

  29. 29

    Writing XMP Metadata in jpeg (with PHP) - Using Single or Multiple rdf:Description blocks

HotTag

Archive