Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/test_image_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def test_p2pa_alpha() -> None:
def test_p2pa_palette() -> None:
with Image.open("Tests/images/tiny.png") as im:
im_pa = im.convert("PA")
assert im_pa.getpalette() == im.getpalette()
assert im_pa.getpalette(None) == im.getpalette()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this None? 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's returning the palette in the current palette mode, rather than the default of RGB - https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.getpalette

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, and .getpalette() calls load no matter what. 👍



rgb2xyz_matrix = (
Expand Down
1 change: 1 addition & 0 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ def convert_transparency(
from . import ImagePalette

new_im.palette = ImagePalette.ImagePalette("RGB", im.getpalette("RGB"))
new_im.palette.dirty = 1
if delete_trns:
# crash fail if we leave a bytes transparency in an rgb/l mode.
del new_im.info["transparency"]
Expand Down