Fix for handling P + transparency -> RGBA conversions

This commit is contained in:
wiredfool 2014-09-20 10:27:52 -07:00
parent bdf845d6df
commit af672b1d7e
2 changed files with 12 additions and 2 deletions

View File

@ -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)

View File

@ -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)