diff --git a/Tests/images/xmp_no_prefix.jpg b/Tests/images/xmp_no_prefix.jpg new file mode 100644 index 000000000..bcd78c7ed Binary files /dev/null and b/Tests/images/xmp_no_prefix.jpg differ diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 904fecebf..217ad74f8 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -898,6 +898,14 @@ class TestFileJpeg: with Image.open("Tests/images/hopper.jpg") as im: assert im.getxmp() == {} + def test_getxmp_no_prefix(self): + with Image.open("Tests/images/xmp_no_prefix.jpg") as im: + if ElementTree is None: + with pytest.warns(UserWarning): + assert im.getxmp() == {} + else: + assert im.getxmp() == {"xmpmeta": {"key": "value"}} + def test_getxmp_padded(self): with Image.open("Tests/images/xmp_padded.jpg") as im: if ElementTree is None: diff --git a/src/PIL/Image.py b/src/PIL/Image.py index a519a28af..6d3715a92 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1380,7 +1380,7 @@ class Image: def _getxmp(self, xmp_tags): def get_name(tag): - return tag.split("}")[1] + return re.sub("^{[^}]+}", "", tag) def get_value(element): value = {get_name(k): v for k, v in element.attrib.items()}