Skip to content

Use TIFF save options as default for appended images #8974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

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
2 participants