diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py index 7c9322754..9202a6d1b 100644 --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -386,6 +386,7 @@ def getheader(im, palette=None, info=None): # calculate the palette size for the header import math colorTableSize = math.ceil(math.log(len(paletteBytes)//3, 2))-1 + if colorTableSize < 0: colorTableSize = 0 s.append(o8(colorTableSize + 128)) # size of global color table + global color table flag s.append(o8(0) + o8(0)) # background + reserved/aspect # end of screen descriptor header diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 336aaba63..3d3d43a7e 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -25,4 +25,4 @@ def test_optimize(): im.save(file, "GIF", optimize=optimize) return len(file.getvalue()) assert_equal(test(0), 800) - assert_equal(test(1), 32) + assert_equal(test(1), 38)