Skip to content

Wait until mode is normalized to copy im.info into encoderinfo - #3187

Merged
hugovk merged 1 commit into
python-pillow:masterfrom
radarhere:encoderinfo
Dec 26, 2018
Merged

hugovk merged 1 commit into
python-pillow:masterfrom
radarhere:encoderinfo

Conversation

@radarhere

Copy link
Copy Markdown
Member

When saving a GIF, any values in im.info are added to im.encoderinfo if the key does not already exist there - https://github.com/python-pillow/Pillow/blob/master/src/PIL/GifImagePlugin.py#L460

In #2803, an RGB image is saved to GIF. GifImagePlugin has a method, _normalize_mode, that converts an RGB mode to P. For the image in that issue, Image's convert method runs del(new.info['transparency']) - https://github.com/python-pillow/Pillow/blob/master/src/PIL/Image.py#L973, deleting the transparency info for the converted image. However, GifImagePlugin has already copied the transparency value from im.info to im.encoderinfo for later use, so the del operation does not have the intended effect.

To fix this, this PR postpones the merging of im.info into im.encoderinfo until after _normalize_mode is run.

@radarhere radarhere added the GIF label Sep 30, 2018
@hugovk
hugovk merged commit bbb3be9 into python-pillow:master Dec 26, 2018
@radarhere
radarhere deleted the encoderinfo branch December 26, 2018 10:58
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.

2 participants