Starting to fill out python xmp toolkit advocacy. #104

This commit is contained in:
jevans 2014-01-30 18:48:56 -05:00
commit f214459ef7

View file

@ -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, 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. one can use ElementTree from the standard library to access the data.
For example, to extract the **CreatorTool** attribute value, the following For example, to extract the **CreatorTool** attribute value, one could do the
would work:: following
>>> xmp = j.box[3].data.packet >>> xmp = j.box[3].data.packet
>>> rdf = '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}' >>> rdf = '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}'
@ -256,8 +256,8 @@ would work::
>>> elt.text >>> elt.text
'Google' 'Google'
Yes, that's painful. A better solution is to install the Python XMP Toolkit But that would be painful. A better solution is to install the Python XMP
(developer branch):: Toolkit::
>>> from libxmp import XMPMeta >>> from libxmp import XMPMeta
>>> from libxmp.consts import XMP_NS_XMP as NS_XAP >>> 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') >>> meta.get_property(NS_XAP, 'CreatorTool')
'Google' '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()