Save as RGB(A) when APNG frames have different palettes - #9870
Merged
radarhere merged 7 commits intoAug 17, 2026
Conversation
APNG has a single PLTE, so saving P-mode frames with different palettes silently rendered every frame with the first palette. Promote the animation to RGB when palettes differ so each frame keeps its colors. Fixes python-pillow#9868
Member
This doesn't address the first and third enhancements. I'm still interested in merging this, but it doesn't resolve the issue completely. |
Signed-off-by: SeaStar Deng <172368758@qq.com>
Member
|
I've created DSeaStar#1 with some suggestions. |
radarhere
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Helps #9868
APNG has a single
PLTE. Saving severalPframes with different palettes previously wrote only the first frame's palette, so later frames rendered with the wrong colors.When the collected palettes differ, the animation is now saved as RGB so each frame keeps its colors. Frames that share one palette stay indexed.
Test plan
Tests/test_file_apng.py::test_apng_save_p_frames_with_different_palettesTests/test_file_apng.py::test_apng_save_p_frames_with_same_paletteTests/test_file_apng.py(49 passed)