Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Tests/test_file_mpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ def test_save_xmp() -> None:
im2.encoderinfo = {"xmp": b"Second frame"}
im_reloaded = roundtrip(im, xmp=b"First frame", save_all=True, append_images=[im2])

# Test that encoderinfo is unchanged
assert im2.encoderinfo == {"xmp": b"Second frame"}

assert im_reloaded.info["xmp"] == b"First frame"

im_reloaded.seek(1)
Expand Down
8 changes: 3 additions & 5 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2551,7 +2551,8 @@ def save(
self.load()

save_all = params.pop("save_all", None)
self.encoderinfo = {**getattr(self, "encoderinfo", {}), **params}
encoderinfo = getattr(self, "encoderinfo", {})
self.encoderinfo = {**encoderinfo, **params}
self.encoderconfig: tuple[Any, ...] = ()

if format.upper() not in SAVE:
Expand Down Expand Up @@ -2589,10 +2590,7 @@ def save(
pass
raise
finally:
try:
del self.encoderinfo
except AttributeError:
pass
self.encoderinfo = encoderinfo
if open_fp:
fp.close()

Expand Down
Loading