Updated 28-Jun-2024
While this is an aspect of a style guide (for the structure of the metadata itself), this is very much a devops document, for use and manipulation of metadata in publishing. The basic point is that certain kinds of information about an image file is most conveniently kept inside the file itself, accessed and manipulated programmatically. One example use is presenting the dimensions of images in web pages using CSS. Since the dimensional information (width and height) is already present in the image itself, there is no reason why that information cannot be read and the CSS generated from it. A more crude, but effective approach is to put this same information in the image filename, in some consistent way. However, there is more information that may be needed, such as title, caption, source, author, date, etc. The best approach would be to ensure that all editors can read (and manipulate) such information, and at the least not discard it.
Preferred Workflow
It would be best if metadata could be added, modified at each stage of editing, and by default would be preserved on copy, export, format changes, compression, etc. Generally things start with or result in various formats, including:
- .svg (native Inkscape)
- .xcf (native GIMP
- .png
- .ico is essentially a .png renamed
- .jpg
- .gif (rarely, if ever)
Metadata Standards
Turns out there is more than one way to stuff a keyword. For JPG there is EXIF, but for PNG or SVG there are other standards, as in PNG does not have EXIF. The common is XMP, an adobe XML format. Also there is IPTC tags. When looking at a file with a tool, generally a few different bits and bobs are present.
In SVG this is a Dublin Core standard, and in PNG the same is generally available.
Image Editors and Metadata Behavior
Currently, the most convenient tools (aka, the ones I use), and their status on JPG Exif and PNG metadata (XMP):
OSX Preview
- Will blank overwrite PNG metadata added by ImageMagick or Exiftool.1 However, if the metadata is written by Inkscape in an SVG file and then exported as PNG, it will read it correctly. This is because Inkscape puts the info in front of IDAT, but the others do not.
- Cannot edit PNG metadata
Inkscape
- Somewhat awkward XML editor for SVG metadata. Don't use this or it will corrupt the file.
- File > Document Metadata provides a nice Dublin Core interface
- Various chunks n stuff in PNG files
GIMP
- EXIF, XMP metadata editor/viewer added as of Gimp 2.9.4 (possibly 2.9.2). It is under the menu > Image > Image Metadata. Note that these are the experimental/unstable releases (stable releases are every few years, so if you want this functionality, have to live on the edge a bit).
- Partha's McGimp variants, the McGimp 2.9.5 64-bit Experimental, or McGimp 2.9.5 64-bit Color Corrected Experimental, are based on 2.9.4 (and are interesting projects in their own right, with HDR extensions and plugins).
- Unfortunately GIMP won't keep metadata in the XCF native GIMP file.
- Too bad this doesn't work, that is it cannot edit metadata in JPG files.
ImageOptim
- Turn off remove metadata options to preserve metadata
ImageMagick
- Can read and write all metadata, but does it in a way that OSX Preview will ignore/overwrite
- If the metadata is originally created by Inkscape, it can edit it in a way that preserves
Exiftool
Turns out that Exiftool sucks equally as bad. Not to mention the university site hosting Exiftool is down.
PNGCommentator
- Like Inkscape, PNGCommentator actually implements things correctly. Oddly, it will show two Titles if one is inserted by ImageMagick or ExifTool. It will also crash a bit.
- Overall, good results. Works well, has wildcard and batch processing options, but only deals with PNG.
Exiv2
So there is this tool called Exiv2 that can do exactly the issue, namely cross-filetype, multi-faceted metadata editing. No Exiv2 binary/DMG for OSX, though lots of people put in the time to compile Exiv2 from source. So, I went the BREW path, as I believe it has fewer issues (for me) than PORTS. First, my BREW was messed up because of Yosemite, but I got this unwedged.
- Note there is a handy NodeJS for Exiv2 as well.
- Too bad the damned thing wouldn't read my files, every attempt said no EXIF or XMP data present
-
Turns out Apple's implementation of XMP in Preview does not follow the specification (what's new here, who'da guessed...) and overwrites XMP if it comes after IDAT. - Supposedly ImageMagick can read and write and not lose anything between JPG and PNG, need to explore this further, as this is unclear with both statements being made. ↩︎