Skip to content

Commit 0084234

Browse files
authored
Merge pull request #10 from radarhere/feature_xmp
Changed list of single items dictionaries to dictionary
2 parents 3e9403a + 3c482b1 commit 0084234

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Tests/test_image_getxmp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33

44
def test_getxmp():
5-
im = Image.open("Tests/images/xmp_test.jpg")
6-
type_repr = repr(type(im.getxmp()))
5+
with Image.open("Tests/images/xmp_test.jpg") as im:
6+
xmp = im.getxmp()
77

8-
assert "dict" in type_repr
9-
assert isinstance(im.getxmp()["Description"][0]["Version"], str)
8+
assert isinstance(xmp, dict)
9+
assert xmp["Description"]["Version"] == "10.4"

src/PIL/Image.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,10 +1334,10 @@ def getxmp(self):
13341334
if marker == b"http://ns.adobe.com/xap/1.0/":
13351335
root = xml.etree.ElementTree.fromstring(xmp_tags)
13361336
for element in root.findall(".//"):
1337-
xmp_atribs = []
1338-
for child, value in element.attrib.items():
1339-
xmp_atribs.append({child.split("}")[1]: value})
1340-
self._xmp.update({element.tag.split("}")[1]: xmp_atribs})
1337+
self._xmp[element.tag.split("}")[1]] = {
1338+
child.split("}")[1]: value
1339+
for child, value in element.attrib.items()
1340+
}
13411341
return self._xmp
13421342

13431343
def getim(self):

0 commit comments

Comments
 (0)