mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
test for issue #2195
This commit is contained in:
parent
2ba2763f0b
commit
915270ef6f
|
@ -362,5 +362,28 @@ class TestFileGif(PillowTestCase):
|
||||||
reread = Image.open(out)
|
reread = Image.open(out)
|
||||||
self.assertEqual(reread.n_frames, 10)
|
self.assertEqual(reread.n_frames, 10)
|
||||||
|
|
||||||
|
def test_transparent_optimize(self):
|
||||||
|
# from issue #2195, if the transparent color is incorrectly
|
||||||
|
# optimized out, gif loses transparency Need a palette that
|
||||||
|
# isn't using the 0 color, and one that's > 128 items where
|
||||||
|
# the transparent color is actually the top palette entry to
|
||||||
|
# trigger the bug.
|
||||||
|
|
||||||
|
from PIL import ImagePalette
|
||||||
|
|
||||||
|
data = bytes(bytearray(range(1,254)))
|
||||||
|
palette = ImagePalette.ImagePalette("RGB", list(range(256))*3)
|
||||||
|
|
||||||
|
im = Image.new('L', (253,1))
|
||||||
|
im.frombytes(data)
|
||||||
|
im.putpalette(palette)
|
||||||
|
|
||||||
|
out = self.tempfile('temp.gif')
|
||||||
|
im.save(out, transparency=253)
|
||||||
|
reloaded = Image.open(out)
|
||||||
|
|
||||||
|
self.assertEqual(reloaded.info['transparency'], 253)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user