Storing metadata in files
Embedded
![© Lead Image © Nasir Khan, 123RF.com © Lead Image © Nasir Khan, 123RF.com](/var/linux_magazin/storage/images/issues/2016/190/xmp-toolkit/nasir_khan_123rf.png/676356-1-eng-US/Nasir_Khan_123RF.png_medium.png)
© Lead Image © Nasir Khan, 123RF.com
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.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.