-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Improved ImagePalette #5552
Improved ImagePalette #5552
Conversation
… color for background or transparency
I've pushed another commit to not use Lines 1012 to 1019 in 52856bc
is currently always going to raise a ValueError. Pillow/src/PIL/ImagePalette.py Lines 142 to 144 in 52856bc
Pillow/src/PIL/ImagePalette.py Lines 90 to 96 in 52856bc
This fixes the UserWarning in #2803 |
assert im.getpixel((0, 0)) == (0, 255, 0, 255) | ||
assert im.getpixel((64, 32)) == (0, 255, 0, 255) | ||
assert im.getpixel((0, 0)) == (255, 0, 0, 0) | ||
assert im.getpixel((64, 32)) == (255, 0, 0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using https://pypi.org/project/apng/ to split Tests/images/apng/mode_palette_alpha.png into frames, this matches the transparent third frame
im_cropped = im_expanded.crop( | ||
(10, 10, im_expanded.width - 10, im_expanded.height - 10) | ||
) | ||
assert_image_equal(im_cropped, im) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now pushed a commit, 'Fixed reloading palette'. It allows this code to work. from PIL import Image
im = Image.open("Tests/images/hopper.gif")
im.load()
im.palette.dirty = 1
im.save("out.png") In master at the moment, it produces this broken output. And with the addition of that change, this PR now resolves #2803 |
This PR has several changes
colors
dictionary is currently empty when the object is created, rather than being filled with palette entries. This fixes thatEdit: Thanks to later commits, resolves #2803