MacOS – How to write ExifTool keywords which Spotlight can see

macosspotlight

I try to write keywords to PNG images using ExifTool but OS X's Spotlight cannot see these keywords at all.

The developer of ExifTool does not know about Spotlight, so he cannot help:

"I wouldn't be surprised if spotlight doesn't parse metadata in PNG images. But I'm not the one to ask about this. I don't know much about how spotlight works."

I have tried many different variations of this but Spotlight don't see my keywords:

/usr/local/bin/exiftool -api PNGEarlyXMP 1 -api IgnoreMinorErrors 1 -Keywords+="my keyword" -overwrite_original_in_place -P path_is_here.png

Limitations in Spotlight, Preview, and Photoshop

Apple Spotlight and Preview (OS X 10.8.5) and Adobe Photoshop CC (version 14.0) ignore XMP in PNG images if it comes after the image data, which is where ExifTool adds new XMP. This should be considered as a bug in the Apple and Adobe software since XMP is allowed to exist after the image data according to the XMP and PNG specifications. [ExifTool 9.40 provides the PNGEarlyXMP API option to allow writing XMP before the IDAT chunk, but there are caveats associated with its use]

PNGEarlyXMP

ExifTool's Flag to write XMP in PNG images before the IDAT (image data) chunk. By default, ExifTool adds new XMP to the end of a PNG file (just before IEND). This is allowed by the PNG and XMP specifications, but some utilities seem to ignore XMP if it comes after the image data. The PNGEarlyXMP option causes ExifTool to instead add new XMP before the PNG IDAT chunk. However, since ExifTool uses a single-pass writing algorithm, it has no way to tell if XMP already exists later in the file before writing the new XMP in this location. If this happens, a minor error is issued when the extra XMP is encountered, and the file is not written. Adding the IgnoreMinorErrors option causes the XMP after IDAT to be deleted, thus resolving the conflict (at the expense of possible metadata loss), and allowing the file to be written. The PNGEarlyXMP option is applied automatically when deleting all XMP and writing new XMP back in one step. When reading, this option causes a warning to be issued if standard XMP is found after the IDAT chunk.

IgnoreMinorErrors

Flag to ignore minor errors. Causes minor errors to be downgraded to warnings, and minor warnings to be ignored. This option is provided mainly to allow writing of files when minor errors occur, but by ignoring some minor warnings the behaviour of ExifTool may be changed to allow some questionable operations to proceed (such as extracting thumbnail and preview images even if they don't have a recognizable header). Minor errors/warnings are denoted by "[minor]" at the start of the message, or "[Minor]" (with a capital "M") for warnings that affect processing when ignored.

Best Answer

As of OS X 10.11, this appears not to be possible.

JPEG but not PNG

That you can not find a working example suggests the Spotlight indexer does not extract the meta-data from Portable Network Graphics, png, files.

According to Searching EXIF data with Mac OS X Spotlight, it does work for jpeg files.

File an Enhancement Bug

Report an enhancement bug through Apple's Bug Reporting web site – and through general OS X feedback. This is the best way to directly tell Apple what you want.