I'd like to update the metadata in a series of jpeg2000 images. And I'd like to do it using python. I've looked at glymur and have been able to extract the xml etree:
import glymur
from lxml import etree
jp2 = glymur.Jp2k(file)
metaroot = jp2.box[3].xml # 4th element in box contains the metadata I want
fitshdr = metaroot[0] # the metadata originated as a fits header
Then I can get tags and tag values:
for kw in fitshdr:
tag = kw.tag
val = fitshdr.findtext(tag)
# do something with tags and values
My question is: Is there an easier way? This seems unnecessarily complicated.