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
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.