Skip to content

When converting RGBA to PA, use RGB to P quantization #9153

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

radarhere
Copy link
Member

Resolves #9151 with two changes.

  1. Currently,
p = hopper("P")
a = Image.new("L", p.size)
pa = Image.merge("PA", (p, a))
print(pa.palette.colors)

returns populated palette data, but

print(pa.getpalette())

is empty. This fixes that.

  1. When converting RGBA to PA, rather than using the C method topalette(), quality can be improved by using the Python quantize() to convert the RGB channels to P, and copying the A channel exactly by using split() and merge().

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.

Overly large PA palette
1 participant