Storing metadata in files
Embedded
With the Python XMP Toolkit, programmers can develop applications that store metadata in files.
Metadata is information about the contents of objects like graphic files, digital videos, or documents and can include the name of a photograph, the author, and the project, as well as details about the license used to publish the item. Subject catalogs, thumbnails, or coordinates of image areas containing faces or other items are also part of the larger realm of metadata.
A range of standards control the exchange of datasets across digital objects. The prevailing technique is to retain the metadata in the file itself and copy that data along with the file. For example, a widespread technical standard for metadata in digital photography is the Exchangeable Image File (Exif) format [1] for JPEG, JFIF, and TIFF images.
With Exif, digital cameras and smartphones can usually write a full range of technical information for inclusion in image data, such as date and time, camera model, focal length, and shutter speed. The standard even includes thumbnails and GPS coordinates.
XMP
Adobe introduced the XMP (Extensible Metadata Platform) standard in 2001. The current version appeared as a three-part specification between 2012 and 2014 [2], with ISO 16684-1-2012 as the core component [3]. XMP provides a comprehensive system for describing the metadata for digital media, consisting of a data model, a serialization or implementation model, and directions for embedding metadata in various file formats.
XMP's data model first stipulates that the metadata within files should all reside in a so-called "packet". That data comes in three variants, as follows: (1) Simple data fields assign an individual content item (e.g., the date of origin) to an element. (2) Structured fields bind an element with several pieces of content (e.g., the dimensions of a document). (3) Lists present data in different ways: as sequential and ordered lists, unordered lists (e.g., keywords), and alternative lists (e.g., a title in different languages).
Embedded
XMP-compatible software embeds the packet directly in the objects described. In doing so, it supports a large range of file formats. XMP packets can be written in image files (JPEG, PNG, TIFF), multimedia formats (AVI, MPEG, MOV, MP3), and digital documents (PDF, PS), as well as in many other formats. The software sets up the metadata in a way that also allows other programs unable to handle the packets to process the files' content without problem.
In TIFF images, for example, XMP uses a block in the image file directory (IFD) with the tag number 0x02BC; the data slots into PDF files, formatted as metadata objects of the XML subtype. For unrecognized formats, such as DjVu, the XMP software creates packets in the form of additional sidecar files with the .xmp
file extension.
You can set the scale of an XMP packet within a file flexibly. The key feature of XMP, however, as its name makes clear, is its expandability. The XMP specification describes many data fields for different purposes; XMP users can augment a file's metadata with their own elements, offering practically unlimited opportunities to expand XMP as desired. For instance, in PDF files it can store identification data used and designed internally for scanned invoices and letters in paperless offices.
Metadata of Exif and other standards may appear side by side in the same graphic file with XMP. Exif tags can also be written in XMP, allowing you to place Exif data in file formats that do not support it by design (e.g., PNG and GIF).
In practice, however, writing several instances of metadata to a single file frequently becomes chaotic. If you want to use individual metadata standards uniformly in image files, you are best advised to follow the guidelines set for this purpose by the Metadata Working Group [4], a consortium of well-known producers of hardware and software.
RDF/XML
XMP packets are programmed in World Wide Web Consortium RDF/XML [5], an XML syntax for serializing Resource Description Framework (RDF) graphs. For the most part, two points could keep the practitioner busy. First, to deal with XMP, you at least need basic XML knowledge. Second, the syntax always disassembles the elements to include individual data (e.g., title and date of origin) in groups or classes sorted by given XML namespaces.
The elements defined by the Dublin Core Metadata Initiative are among the primary components of XMP. Dublin Core [6] is a rudimentary set comprising 15 core elements belonging to the dc
namespace, which also uniformly describes objects of different types, such as photos, videos, and books.
It is therefore mostly elements like dc:title
, dc:creator
, dc:description
, and so on that are present in XMP packets of various file formats. The description elements in the xmp
namespace function as the further core components of XMP: for instance, xmp:CreateDate
and xmp:CreatorTool
.
The xmlns
element creates namespaces and generally binds them with a uniform resource identifier (URI) – usually an HTTP address. If you know XML, you know that such HTTP addresses are only for registration. They do not need to contain real websites on the Internet. The creators can define namespace identifiers on publication of their sets. The dc
namespace, for instance, belongs to the URI http://purl.org/dc/elements/1.1/, and the xmp
namespace belongs to http://ns.adobe.com/xap/1.0/.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.