mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Merge pull request #8 from wiredfool/hugo-png-trns
Fix for handling P + transparency -> RGBA conversions
This commit is contained in:
commit
fd28666238
10
PIL/Image.py
10
PIL/Image.py
|
@ -867,8 +867,18 @@ 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)
|
||||
new = self._new(im)
|
||||
|
|
|
@ -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