mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
Fix for handling P + transparency -> RGBA conversions
This commit is contained in:
parent
bdf845d6df
commit
af672b1d7e
10
PIL/Image.py
10
PIL/Image.py
|
@ -867,7 +867,17 @@ class Image:
|
|||
trns = trns_im.getpixel((0,0))
|
||||
|
||||
elif self.mode == 'P' and mode == 'RGBA':
|
||||
t = self.info['transparency']
|
||||
delete_trns = True
|
||||
|
||||
if isinstance(t, bytes):
|
||||
self.im.putpalettealphas(t)
|
||||
elif isinstance(t, int):
|
||||
self.im.putpalettealpha(t,0)
|
||||
else:
|
||||
raise ValueError("Transparency for P mode should" +
|
||||
" be bytes or int")
|
||||
|
||||
|
||||
if mode == "P" and palette == ADAPTIVE:
|
||||
im = self.im.quantize(colors)
|
||||
|
|
|
@ -347,8 +347,8 @@ class TestFilePng(PillowTestCase):
|
|||
im2 = Image.open(f)
|
||||
self.assertIn('transparency', im2.info)
|
||||
|
||||
self.assert_image_similar(im2.convert('RGBA'), im.convert('RGBA'),
|
||||
16)
|
||||
self.assert_image_equal(im2.convert('RGBA'),
|
||||
im.convert('RGBA'))
|
||||
|
||||
def test_save_icc_profile_none(self):
|
||||
# check saving files with an ICC profile set to None (omit profile)
|
||||
|
|
Loading…
Reference in New Issue
Block a user