mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
Do not require curly bracket in tag name
This commit is contained in:
parent
2488167f33
commit
3f78ba80f9
BIN
Tests/images/xmp_no_prefix.jpg
Normal file
BIN
Tests/images/xmp_no_prefix.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 788 B |
|
@ -898,6 +898,14 @@ class TestFileJpeg:
|
||||||
with Image.open("Tests/images/hopper.jpg") as im:
|
with Image.open("Tests/images/hopper.jpg") as im:
|
||||||
assert im.getxmp() == {}
|
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):
|
def test_getxmp_padded(self):
|
||||||
with Image.open("Tests/images/xmp_padded.jpg") as im:
|
with Image.open("Tests/images/xmp_padded.jpg") as im:
|
||||||
if ElementTree is None:
|
if ElementTree is None:
|
||||||
|
|
|
@ -1380,7 +1380,7 @@ class Image:
|
||||||
|
|
||||||
def _getxmp(self, xmp_tags):
|
def _getxmp(self, xmp_tags):
|
||||||
def get_name(tag):
|
def get_name(tag):
|
||||||
return tag.split("}")[1]
|
return re.sub("^{[^}]+}", "", tag)
|
||||||
|
|
||||||
def get_value(element):
|
def get_value(element):
|
||||||
value = {get_name(k): v for k, v in element.attrib.items()}
|
value = {get_name(k): v for k, v in element.attrib.items()}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user