Skip to content

Conversation

@jvanderneutstulen
Copy link
Contributor

@jvanderneutstulen jvanderneutstulen commented May 24, 2025

Fixes #8963. Alternative to #9001

Changes proposed in this pull request:

  • Use TIFF encoderinfo of first image as default for appended images

jvanderneutstulen and others added 2 commits May 23, 2025 15:30
If no encoderinfo is specified on an appended TIFF image, use the
encoder info from the first image. This restores 11.1.0 behavior,
while allowing an image specific override.
@radarhere radarhere added the TIFF label May 24, 2025
@radarhere radarhere changed the title Use tiff save options as default for appended images Use TIFF save options as default for appended images May 24, 2025
@radarhere
Copy link
Member

#8963 (comment)

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.

@hugovk
Copy link
Member

hugovk commented Jun 30, 2025

Thanks for the PR and issue, #9001 has been merged instead.

@hugovk hugovk closed this Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TIFF save options are not applied to appended images

3 participants