Some image formats support embedded metadata, which may contain information about image characteristics, as well as user- and/or device-supplied information about authoring, copyright, camera settings, and so on. This metadata may be encoded in a standard cross-format encoding like EXIF, IPTC IIM, or XMP, or it may use an encoding that is specific to a particular image format. More than one encoding may be present in the same file.
During a response, an entirely new image is generated and returned to the client. In some cases it might be desired that this image contain some subset of metadata from the source image, or all of it, or that new metadata be added to it.
Typically written by devices like cameras and scanners and not meant to be edited. Uses the TIFF file format (consisting of "directories," "tags," and "fields") for serialization, and many terms overlap with the ones in the "Baseline TIFF" specification. Terms can also be represented in XMP.
Serialization and vocabulary developed by the IPTC. Simple binary encoding with a fixed vocabulary. The serialization is not used much anymore, but the vocabulary has been migrated to the "IPTC Core" schema used in XMP.
RDF-based encoding developed by Adobe. Widely supported across many formats and even non-image media files. May contain terms from the EXIF and IPTC standards as well as from other vocabularies. The current de facto embedded metadata standard, generally.
Native standards
Some image formats define their own metadata standards. PNG and TIFF define small term vocabularies, for example.
Metadata can be returned in IIIF Image API information responses using an extra_iiifn_information_response_keys() delegate method. (This requires Cantaloupe 5.0.3 or later.) An example follows:
This will cause keys such as the following to be added to an information response:
Note that the view is into the low-level metadata structures without any higher-level categorization. For example, EXIF metadata may be present in the exif key, but it may also be present in the XMP string.
EXIF string values ending with == are typically base64-encoded binary data.
Copying & Mutating
While several different source metadata formats can be read, only XMP can be written. This simplifies the metadata API and reduces crosswalking challenges, as XMP is flexible enough to express EXIF and IIM with no information loss. XMP can also be embedded into many image formats and is widely supported by imaging software.
XMP is serialized as RDF/XML. A very simple XMP packet might look like:
Note that the XMP standard is quite complex and is based on RDF, which itself is complex, so what follows is not implied to be a replacement for the several hundred pages of reading needed to fully grasp those respective standards.
Verbatim Copying
The above XMP packet can be copied verbatim from a source image into derivative images quite easily:
Adding Properties
Continuing with the example above, we assume that the source image's IPTC metadata contains a copyright statement that we'd like to copy into derivative images' XMP data.
According to the IPTC IIM specification, the tag most likely to contain a copyright statement is CopyrightNotice (p. 39). We will choose to translate this into a Dublin Core rights element in XMP.
Modifying Properties
In this example, we want to remove any dc:title property that may be present in the source XMP, and add our own. We use Jena, which is bundled into the application, to do this.
Implementation Notes
After metadata is initially read from a source image, it may be cached, in which case subsequent requests will read it from the cache rather than the source image. In this case, changes to the source image's metadata will not be reflected in the application until the cached metadata becomes invalid and is re-read. If you need to change a source image's metadata, you should manually purge any cached content relating to it afterwards.
IPTC IIM supports many different character encodings, but Cantaloupe supports only UTF-8, ASCII, and ISO Latin 1, all of which get converted to UTF-8 internally.