mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 02:36:17 +03:00
Allow encoderinfo to be set for appended images
This commit is contained in:
parent
98f975dbbe
commit
203ca12626
|
@ -293,3 +293,15 @@ def test_save_all() -> None:
|
|||
# Test that a single frame image will not be saved as an MPO
|
||||
jpg = roundtrip(im, save_all=True)
|
||||
assert "mp" not in jpg.info
|
||||
|
||||
|
||||
def test_save_xmp() -> None:
|
||||
im = Image.new("RGB", (1, 1))
|
||||
im2 = Image.new("RGB", (1, 1), "#f00")
|
||||
im2.encoderinfo = {"xmp": b"Second frame"}
|
||||
im_reloaded = roundtrip(im, xmp=b"First frame", save_all=True, append_images=[im2])
|
||||
|
||||
assert im_reloaded.info["xmp"] == b"First frame"
|
||||
|
||||
im_reloaded.seek(1)
|
||||
assert im_reloaded.info["xmp"] == b"Second frame"
|
||||
|
|
|
@ -2565,7 +2565,7 @@ class Image:
|
|||
self._ensure_mutable()
|
||||
|
||||
save_all = params.pop("save_all", False)
|
||||
self.encoderinfo = params
|
||||
self.encoderinfo = {**getattr(self, "encoderinfo", {}), **params}
|
||||
self.encoderconfig: tuple[Any, ...] = ()
|
||||
|
||||
preinit()
|
||||
|
@ -2612,6 +2612,11 @@ class Image:
|
|||
except PermissionError:
|
||||
pass
|
||||
raise
|
||||
finally:
|
||||
try:
|
||||
del self.encoderinfo
|
||||
except AttributeError:
|
||||
pass
|
||||
if open_fp:
|
||||
fp.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user