mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-09-24 13:07:00 +03:00
Load image palette into Python after converting to PA
This commit is contained in:
parent
092d4422d5
commit
6d974b61d6
|
@ -107,6 +107,14 @@ def test_rgba_p() -> None:
|
||||||
assert_image_similar(im, comparable, 20)
|
assert_image_similar(im, comparable, 20)
|
||||||
|
|
||||||
|
|
||||||
|
def test_pa() -> None:
|
||||||
|
im = hopper().convert("PA")
|
||||||
|
|
||||||
|
palette = im.palette
|
||||||
|
assert palette is not None
|
||||||
|
assert palette.colors != {}
|
||||||
|
|
||||||
|
|
||||||
def test_rgba() -> None:
|
def test_rgba() -> None:
|
||||||
with Image.open("Tests/images/transparent.png") as im:
|
with Image.open("Tests/images/transparent.png") as im:
|
||||||
assert im.mode == "RGBA"
|
assert im.mode == "RGBA"
|
||||||
|
|
|
@ -1143,7 +1143,7 @@ class Image:
|
||||||
raise ValueError(msg) from e
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
new_im = self._new(im)
|
new_im = self._new(im)
|
||||||
if mode == "P" and palette != Palette.ADAPTIVE:
|
if mode in ("P", "PA") and palette != Palette.ADAPTIVE:
|
||||||
from . import ImagePalette
|
from . import ImagePalette
|
||||||
|
|
||||||
new_im.palette = ImagePalette.ImagePalette("RGB", im.getpalette("RGB"))
|
new_im.palette = ImagePalette.ImagePalette("RGB", im.getpalette("RGB"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user