mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-09-24 13:07:00 +03:00
When converting RGBA to PA, use RGB to P quantization
This commit is contained in:
parent
0ae2611b44
commit
ba66fec3d2
|
@ -107,6 +107,13 @@ def test_rgba_p() -> None:
|
||||||
assert_image_similar(im, comparable, 20)
|
assert_image_similar(im, comparable, 20)
|
||||||
|
|
||||||
|
|
||||||
|
def test_rgba_pa() -> None:
|
||||||
|
im = hopper("RGBA").convert("PA").convert("RGB")
|
||||||
|
expected = hopper("RGB")
|
||||||
|
|
||||||
|
assert_image_similar(im, expected, 9.3)
|
||||||
|
|
||||||
|
|
||||||
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"
|
||||||
|
|
|
@ -1010,8 +1010,14 @@ class Image:
|
||||||
new_im.info["transparency"] = transparency
|
new_im.info["transparency"] = transparency
|
||||||
return new_im
|
return new_im
|
||||||
|
|
||||||
if mode == "P" and self.mode == "RGBA":
|
if self.mode == "RGBA":
|
||||||
|
if mode == "P":
|
||||||
return self.quantize(colors)
|
return self.quantize(colors)
|
||||||
|
elif mode == "PA":
|
||||||
|
r, g, b, a = self.split()
|
||||||
|
rgb = merge("RGB", (r, g, b))
|
||||||
|
p = rgb.quantize(colors)
|
||||||
|
return merge("PA", (p, a))
|
||||||
|
|
||||||
trns = None
|
trns = None
|
||||||
delete_trns = False
|
delete_trns = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user