Skip to content
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

Keep transparency when converting from P to LA or PA #5606

Merged
merged 1 commit into from Aug 13, 2021

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Jul 12, 2021

Resolves #5593, fixing the second problem in that issue.

At the moment, there is code in convert() to keep transparency when going from P to RGBA.

Pillow/src/PIL/Image.py

Lines 1008 to 1017 in be30792

elif self.mode == "P" and mode == "RGBA":
t = self.info["transparency"]
delete_trns = True
if isinstance(t, bytes):
self.im.putpalettealphas(t)
elif isinstance(t, int):
self.im.putpalettealpha(t, 0)
else:
raise ValueError("Transparency for P mode should be bytes or int")

This PR expands the condition to do the same if going from P to LA or PA as well.

@hugovk hugovk merged commit 3d35e54 into python-pillow:master Aug 13, 2021
@radarhere radarhere deleted the convert_transparency branch August 13, 2021 10:19
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.

8.3.0: convert on a P image with transparency now returns a RGB image (used to be RGBA)
2 participants