diff --git a/docs/source/how_do_i.rst b/docs/source/how_do_i.rst index c5a411d..12c6a04 100644 --- a/docs/source/how_do_i.rst +++ b/docs/source/how_do_i.rst @@ -27,3 +27,35 @@ display just raw codestream as well. This will display metadata present in the codestream's main header only. :: >>> print(j.get_codestream()) + +Work with XMP UUIDs? +==================== +The example JP2 file shipped with glymur has an XMP UUID:: + + >>> import pkg_resources + >>> from glymur import Jp2k + >>> file = pkg_resources.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> j = Jp2k(file) + >>> print(j.box[4]) + UUID Box (uuid) @ (715, 2412) + UUID: be7acfcb-97a9-42e8-9c71-999491e3afac (XMP) + UUID Data: + + + + + + +Since the UUID data in this case is returned as an ElementTree Element, one can +use ElementTree to access the data. For example, to extract the +**CreatorTool** attribute value, the following would work:: + + >>> xmp = j.box[4].data + >>> ns0 = '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}' + >>> ns1 = '{http://ns.adobe.com/xap/1.0/}' + >>> name = '{0}RDF/{0}Description'.format(ns0) + >>> elt = xmp.find(name) + >>> elt + + >>> elt.attrib['{0}CreatorTool'.format(ns1)] + 'glymur'