Merge pull request #1273 from radarhere/gif

Added background saving to GifImagePlugin
This commit is contained in:
Hugo van Kemenade 2015-06-16 15:03:25 +03:00
commit 200ae2adb3
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()