xmp feature

This commit is contained in:
UrielMaD 2020-12-26 00:51:02 -06:00
parent 895fa4d39c
commit 1159cb8afb

View File

@ -539,6 +539,7 @@ class Image:
self.readonly = 0 self.readonly = 0
self.pyaccess = None self.pyaccess = None
self._exif = None self._exif = None
self._xmp = None
@property @property
def width(self): def width(self):
@ -1320,22 +1321,21 @@ class Image:
def getxmp(self): def getxmp(self):
xmp = {}
for segment, content in self.applist: for segment, content in self.applist:
if segment == 'APP1': if segment == 'APP1':
marker, xmp_tags = content.rsplit(b'\x00', 1) marker, xmp_tags = content.rsplit(b'\x00', 1)
#print(marker)
print(xmp_tags)
if marker == b'http://ns.adobe.com/xap/1.0/': if marker == b'http://ns.adobe.com/xap/1.0/':
print(xmp_tags.decode('latin-1'))
root = xml.etree.ElementTree.fromstring(xmp_tags) root = xml.etree.ElementTree.fromstring(xmp_tags)
print(root)
for element in root.findall('.//'): for element in root.findall('.//'):
print(element.tag.split('}')[1]) xmp_atribs = []
print(element.attrib)
for child, value in element.attrib.items(): for child, value in element.attrib.items():
print(child.split('}')[1] + ": " + value) xmp_atribs.append({child.split('}')[1]: value})
xmp.update({element.tag.split('}')[1]: atrib})
return root
return xmp
def getim(self): def getim(self):
""" """