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

Image channel is used when converting PA with an RGBA palette #6662

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Oct 13, 2022

Resolves #6658

This PR documents that when converting a PA image with an RGBA palette, the alpha values from the image are used, rather than the values from the palette.

from PIL import Image, ImagePalette
im = Image.new("PA", (1, 2))
p = ImagePalette.ImagePalette("RGBA")
first = p.getcolor((1, 2, 3, 4))
second = p.getcolor((5, 6, 7, 8))
im.putpalette(p)
im.putpixel((0, 0), (first, 100))
im.putpixel((0, 1), (second, 200))

im_rgba = im.convert("RGBA")
print("(0, 0):", im_rgba.load()[0, 0])
print("(0, 1):", im_rgba.load()[0, 1])

gives

(0, 0): (1, 2, 3, 100)
(0, 1): (5, 6, 7, 200)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document alpha values of PA image with RGBA palette
2 participants