Added background color index saving to GifImagePlugin

This commit is contained in:
Andrew Murray 2015-06-11 11:10:05 +10:00
parent 67c75061d2
commit ecb1cef99b
2 changed files with 11 additions and 1 deletions

View File

@ -537,7 +537,8 @@ def getheader(im, palette=None, info=None):
# size of global color table + global color table flag
header.append(o8(color_table_size + 128))
# background + reserved/aspect
header.append(o8(0) + o8(0))
background = im.info["background"] if "background" in im.info else 0
header.append(o8(background) + o8(0))
# end of Logical Screen Descriptor
# add the missing amount of bytes

View File

@ -201,6 +201,15 @@ class TestFileGif(PillowTestCase):
self.assertEqual(reread.info['loop'], number_of_loops)
def test_background(self):
out = self.tempfile('temp.gif')
im = Image.new('L', (100, 100), '#000')
im.info['background'] = 1
im.save(out)
reread = Image.open(out)
self.assertEqual(reread.info['background'], im.info['background'])
if __name__ == '__main__':
unittest.main()