From f214459ef7fe0ab34686e0dd5467d2910c731cda Mon Sep 17 00:00:00 2001 From: jevans Date: Thu, 30 Jan 2014 18:48:56 -0500 Subject: [PATCH] Starting to fill out python xmp toolkit advocacy. #104 --- docs/source/how_do_i.rst | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/source/how_do_i.rst b/docs/source/how_do_i.rst index 443e8db..e620dbc 100644 --- a/docs/source/how_do_i.rst +++ b/docs/source/how_do_i.rst @@ -243,8 +243,8 @@ The example JP2 file shipped with glymur has an XMP UUID. :: Since the UUID data in this case is returned as an ElementTree instance, one can use ElementTree from the standard library to access the data. -For example, to extract the **CreatorTool** attribute value, the following -would work:: +For example, to extract the **CreatorTool** attribute value, one could do the +following >>> xmp = j.box[3].data.packet >>> rdf = '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}' @@ -256,8 +256,8 @@ would work:: >>> elt.text 'Google' -Yes, that's painful. A better solution is to install the Python XMP Toolkit -(developer branch):: +But that would be painful. A better solution is to install the Python XMP +Toolkit:: >>> from libxmp import XMPMeta >>> from libxmp.consts import XMP_NS_XMP as NS_XAP @@ -266,3 +266,16 @@ Yes, that's painful. A better solution is to install the Python XMP Toolkit >>> meta.get_property(NS_XAP, 'CreatorTool') 'Google' +Where the Python XMP Toolkit can really shine, though, is when you are +converting an image from another format such as TIFF or JPEG into JPEG 2000. +For example:: + + >>> import requests + >>> r = requests.get('http://photojournal.jpl.nasa.gov/tiff/PIA17145.tif') + >>> with open('PIA17145.tif', 'wb') as fptr: fptr.write(r.content) + >>> from libxmp import XMPFiles + >>> xf = XMPFile() + >>> xf.open_file('PIA17145.tif') + >>> xmp = xf.get_xmp() + +