Storing metadata in files

Embedded

© Lead Image © Nasir Khan, 123RF.com

© Lead Image © Nasir Khan, 123RF.com

Article from Issue 190/2016
Author(s):

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

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News

njobs Europe
What:
Where:
Country:
Njobs Netherlands Njobs Deutschland Njobs United Kingdom Njobs Italia Njobs France Njobs Espana Njobs Poland
Njobs Austria Njobs Denmark Njobs Belgium Njobs Czech Republic Njobs Mexico Njobs India Njobs Colombia