Skip to content
Closed
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
8 changes: 6 additions & 2 deletions Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,19 @@ def test_rowsperstrip(self, tmp_path: Path) -> None:
im = hopper()
im2 = Image.new("L", (128, 128))
im2.encoderinfo = {"tiffinfo": {278: 256}}
im.save(outfile, save_all=True, append_images=[im2])
im3 = Image.new("L", (128, 128))
im.save(outfile, save_all=True, append_images=[im2, im3], tiffinfo={278: 512})

with Image.open(outfile) as im:
assert isinstance(im, TiffImagePlugin.TiffImageFile)
assert im.tag_v2[278] == 128
assert im.tag_v2[278] == 512

im.seek(1)
assert im.tag_v2[278] == 256

im.seek(2)
assert im.tag_v2[278] == 512

def test_strip_raw(self) -> None:
infile = "Tests/images/tiff_strip_raw.tif"
with Image.open(infile) as im:
Expand Down
8 changes: 5 additions & 3 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,7 +2302,9 @@ def fixOffsets(


def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
append_images = list(im.encoderinfo.get("append_images", []))
encoderinfo = im.encoderinfo.copy()
encoderconfig = im.encoderconfig
append_images = list(encoderinfo.get("append_images", []))
if not hasattr(im, "n_frames") and not append_images:
return _save(im, fp, filename)

Expand All @@ -2311,9 +2313,9 @@ def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
with AppendingTiffWriter(fp) as tf:
for ims in [im] + append_images:
if not hasattr(ims, "encoderinfo"):
ims.encoderinfo = {}
ims.encoderinfo = encoderinfo
if not hasattr(ims, "encoderconfig"):
ims.encoderconfig = ()
ims.encoderconfig = encoderconfig
nfr = getattr(ims, "n_frames", 1)

for idx in range(nfr):
Expand Down
Loading