diff --git a/Tests/test_image_getxmp.py b/Tests/test_image_getxmp.py index 91c6634f1..a684d6f0c 100644 --- a/Tests/test_image_getxmp.py +++ b/Tests/test_image_getxmp.py @@ -2,8 +2,8 @@ from PIL import Image def test_getxmp(): - im = Image.open("Tests/images/xmp_test.jpg") - type_repr = repr(type(im.getxmp())) + with Image.open("Tests/images/xmp_test.jpg") as im: + xmp = im.getxmp() - assert "dict" in type_repr - assert isinstance(im.getxmp()["Description"][0]["Version"], str) + assert isinstance(xmp, dict) + assert xmp["Description"]["Version"] == "10.4" diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 63468df99..df78fb809 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1334,10 +1334,10 @@ class Image: if marker == b"http://ns.adobe.com/xap/1.0/": root = xml.etree.ElementTree.fromstring(xmp_tags) for element in root.findall(".//"): - xmp_atribs = [] - for child, value in element.attrib.items(): - xmp_atribs.append({child.split("}")[1]: value}) - self._xmp.update({element.tag.split("}")[1]: xmp_atribs}) + self._xmp[element.tag.split("}")[1]] = { + child.split("}")[1]: value + for child, value in element.attrib.items() + } return self._xmp def getim(self):