Skip to content

If first GIF frame has transparency for RGB_ALWAYS loading strategy, use RGBA mode#6592

Merged
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:gif_rgba
Oct 12, 2022
Merged

If first GIF frame has transparency for RGB_ALWAYS loading strategy, use RGBA mode#6592
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:gif_rgba

Conversation

@radarhere
Copy link
Copy Markdown
Member

Resolves #6590

At the moment, the first frame of a GIF is never RGBA.

if frame == 0:
if self._frame_palette:
self.mode = (
"RGB" if LOADING_STRATEGY == LoadingStrategy.RGB_ALWAYS else "P"
)
else:
self.mode = "L"

This PR changes it to be RGBA if there is transparency and LoadingStrategy.RGB_ALWAYS is used. In that situation, transparency should not be set in the info dictionary, because the transparency is a palette index, and the image is in RGBA mode.

@radarhere radarhere added the GIF label Sep 17, 2022
@radarhere radarhere changed the title If first frame has transparency for RGB_ALWAYS loading strategy, use RGBA mode If first GIF frame has transparency for RGB_ALWAYS loading strategy, use RGBA mode Sep 17, 2022
@hugovk hugovk merged commit cf3132b into python-pillow:main Oct 12, 2022
@radarhere radarhere deleted the gif_rgba branch October 12, 2022 10:53
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.

First frame of transparent GIF is read incorrectly

2 participants