XMP Reader
XMP Reader in Ruby. Parse XMP data extracted from an image into rich data types.
Usage
Use something like imagemagick to extract the XMP, then read it with this class:
require "xmpr"
raw_xmp = `convert image.jpg xmp:-`
xmp = XMPR.parse(raw_xmp)
xmp["dc", "title"] # => "Amazing Photo"
xmp["photoshop", "Category"] # => "summer"
xmp["photoshop", "SupplementalCategories"] # => ["morning", "sea"]
The xmp instance fetches namespaced attributes. You can use fully qualified namespaces, or some namespaces have shortcuts:
xmp["http://purl.org/dc/elements/1.1/", "title"] # => "Amazing Photo"
xmp["dc", "title"] # => "Amazing Photo" (same thing)
The following namespaces have shortcuts:
-
aux
—http://ns.adobe.com/exif/1.0/aux/
-
cc
—http://creativecommons.org/ns#
(Creative Commons) -
crs
—http://ns.adobe.com/camera-raw-settings/1.0/
-
dc
—http://purl.org/dc/elements/1.1/
(Dublin Core) -
exif
—http://ns.adobe.com/exif/1.0/
-
Iptc4xmpCore
—http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/
(IPTC) -
pdf
—http://ns.adobe.com/pdf/1.3/
-
photoshop
—http://ns.adobe.com/photoshop/1.0/
-
rdf
—http://www.w3.org/1999/02/22-rdf-syntax-ns#
-
tiff
—http://ns.adobe.com/tiff/1.0/
-
x
—adobe:ns:meta/
-
xap
—http://ns.adobe.com/xap/1.0/
-
xmp
—http://ns.adobe.com/xap/1.0/
(XMP) -
xmpidq
—http://ns.adobe.com/xmp/Identifier/qual/1.0/
-
xmpBJ
—http://ns.adobe.com/xap/1.0/bj/
-
xmpRights
—http://ns.adobe.com/xap/1.0/rights/
-
xmpMM
—http://ns.adobe.com/xap/1.0/mm/
-
xmpTPg
—http://ns.adobe.com/xap/1.0/t/pg/
Thanks
Refactored from XMP. Inspired by ExifTool.
References
License
MIT license, see LICENSE.