Pillow
Pillow copied to clipboard
Use TIFF save options as default for appended images
Fixes #8963. Alternative to #9001
Changes proposed in this pull request:
- Use TIFF encoderinfo of first image as default for appended images
https://github.com/python-pillow/Pillow/issues/8963#issuecomment-2903736178
I guess the current strategy in Image.save (stash the params into encoderinfo and later let the plugin's _save_all parse that) will need to be refined to distinguish between globally set parameters and parameters originally set on the first frame's encoderinfo but not to be applied to all frames, though.
This PR doesn't make this distinction. If I adjust your code so that encoderinfo is applied to the first frame,
diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py
index 35b2aa0e3..2a475910c 100644
--- a/Tests/test_file_tiff.py
+++ b/Tests/test_file_tiff.py
@@ -694,6 +694,7 @@ class TestFileTiff:
assert im.tag_v2[278] == 256
im = hopper()
+ im.encoderinfo = {"tiffinfo": {278: 100}}
im2 = Image.new("L", (128, 128))
im2.encoderinfo = {"tiffinfo": {278: 256}}
im3 = Image.new("L", (128, 128))
@@ -701,7 +702,7 @@ class TestFileTiff:
with Image.open(outfile) as im:
assert isinstance(im, TiffImagePlugin.TiffImageFile)
- assert im.tag_v2[278] == 512
+ assert im.tag_v2[278] == 100
im.seek(1)
assert im.tag_v2[278] == 256
the test fails - https://github.com/radarhere/Pillow/actions/runs/15504472075/job/43657452711#step:11:2607
I've created #9001 instead.
Thanks for the PR and issue, https://github.com/python-pillow/Pillow/pull/9001 has been merged instead.