mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
Added getxmp() to WebPImagePlugin
This commit is contained in:
parent
ad938d5421
commit
58cbcbf108
|
@ -11,6 +11,11 @@ pytestmark = [
|
||||||
skip_unless_feature("webp_mux"),
|
skip_unless_feature("webp_mux"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
try:
|
||||||
|
from defusedxml import ElementTree
|
||||||
|
except ImportError:
|
||||||
|
ElementTree = None
|
||||||
|
|
||||||
|
|
||||||
def test_read_exif_metadata():
|
def test_read_exif_metadata():
|
||||||
|
|
||||||
|
@ -110,6 +115,22 @@ def test_read_no_exif():
|
||||||
assert not webp_image._getexif()
|
assert not webp_image._getexif()
|
||||||
|
|
||||||
|
|
||||||
|
def test_getxmp():
|
||||||
|
with Image.open("Tests/images/flower.webp") as im:
|
||||||
|
assert "xmp" not in im.info
|
||||||
|
assert im.getxmp() == {}
|
||||||
|
|
||||||
|
with Image.open("Tests/images/flower2.webp") as im:
|
||||||
|
if ElementTree is None:
|
||||||
|
with pytest.warns(UserWarning):
|
||||||
|
assert im.getxmp() == {}
|
||||||
|
else:
|
||||||
|
assert (
|
||||||
|
im.getxmp()["xmpmeta"]["xmptk"]
|
||||||
|
== "Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27 "
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("webp_anim")
|
@skip_unless_feature("webp_anim")
|
||||||
def test_write_animated_metadata(tmp_path):
|
def test_write_animated_metadata(tmp_path):
|
||||||
iccp_data = b"<iccp_data>"
|
iccp_data = b"<iccp_data>"
|
||||||
|
|
|
@ -98,6 +98,9 @@ class WebPImageFile(ImageFile.ImageFile):
|
||||||
return None
|
return None
|
||||||
return self.getexif()._get_merged_dict()
|
return self.getexif()._get_merged_dict()
|
||||||
|
|
||||||
|
def getxmp(self):
|
||||||
|
return self._getxmp(self.info["xmp"]) if "xmp" in self.info else {}
|
||||||
|
|
||||||
def seek(self, frame):
|
def seek(self, frame):
|
||||||
if not self._seek_check(frame):
|
if not self._seek_check(frame):
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user