Skip to content

Fix for #653 - animated gifs with mode "P" errors#657

Closed
benzkji wants to merge 1 commit into
SmileyChris:masterfrom
benzkji:fix/653-p-mode-gif
Closed

Fix for #653 - animated gifs with mode "P" errors#657
benzkji wants to merge 1 commit into
SmileyChris:masterfrom
benzkji:fix/653-p-mode-gif

Conversation

@benzkji

@benzkji benzkji commented Jan 7, 2025

Copy link
Copy Markdown
Contributor

@jrief @SmileyChris somehow the FrameAware wrapper did not always preserve the mode.

I was thinking about adding a "THUMBNAIL_PRESERVE_ANIMATIONS = False", so one can easily completly disable animated stuff. Even when not saving the frames, they are currently processed anyway, thus running into potential performance issues.

@benzkji

benzkji commented Jan 8, 2025

Copy link
Copy Markdown
Contributor Author

@jrief @SmileyChris to be clear, this is an somewhat urgent bugfix, for a regression (see #653 ) that was introduced by my animated formats support PR that was merged for version 2.10. THUMBNAIL_PRESERVE_ANIMATIONS is for later.

@philippemilink

Copy link
Copy Markdown

Can we expect this PR to be merged soon and a release to be published, please?

@benzkji

benzkji commented May 7, 2025

Copy link
Copy Markdown
Contributor Author

Let's see if @SmileyChris or @jrief see this.

@benkonrath

Copy link
Copy Markdown
Contributor

@benzkji Quick question about this fix: I noticed that the resulting thumbnail is not animated for animated mode P GIFs. You can see this by replacing the last line in the test with this:

            # ...
            thumb = t.get_thumbnail({'size': (500, 50), 'crop': True})
            self.assertTrue(getattr(thumb.image, "is_animated", False))

It looks like to_return = to_return.convert(new_frames[0].mode) removes the animation on the latest version of Pillow (pillow==11.2.1). Is this the expected result?

I've set THUMBNAIL_IMAGE_SAVE_OPTIONS correctly, e.g.:

THUMBNAIL_IMAGE_SAVE_OPTIONS = {
    # ...
    "PNG": {
        "save_all": True,
    },
    "GIF": {
        "save_all": True,
    },
}

I've also tested with animated PNGs and that is working. Any idea?

@benzkji

benzkji commented Jun 8, 2025

Copy link
Copy Markdown
Contributor Author

@benkonrath yes. It is the workaround. I've not found a way to correctly process the example GIF from this PR, so I thought, better strip animations and have something working. I was not able to spend a lot of time on the problem though, I'm sure there is a solution. But Pillow is sometimes tricky, I must admit.

@benzkji

benzkji commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@benkonrath PR is better #662

@benzkji benzkji closed this May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants