fix gif test, fix gif optimization for palette length < 3

This commit is contained in:
David Schmidt 2013-05-23 15:24:06 +02:00
parent 5cd1b9f01e
commit dad5e86226
2 changed files with 2 additions and 1 deletions

View File

@ -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

View File

@ -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)