Force include colour table for disposal=2 gifs and pad colour table to be valid when flag is set

This commit is contained in:
Riley Lahd 2019-03-14 14:41:10 -06:00
parent 96c5a4c543
commit 8a36a15ebd

View File

@ -476,6 +476,9 @@ def _write_multiple_frames(im, fp, palette):
if len(im_frames) > 1:
for frame_data in im_frames:
im_frame = frame_data['im']
if("disposal" in frame_data["encoderinfo"] \
and frame_data["encoderinfo"]["disposal"]==2):
frame_data['encoderinfo']['include_color_table'] = True
if not frame_data['bbox']:
# global header
for s in _get_global_header(im_frame,
@ -585,6 +588,8 @@ def _write_local_header(fp, im, offset, flags):
include_color_table = im.encoderinfo.get('include_color_table')
if include_color_table:
palette_bytes = _get_palette_bytes(im)
# If needed, expand palette to minimum size
while(len(palette_bytes)<9): palette_bytes = palette_bytes*2
color_table_size = _get_color_table_size(palette_bytes)
if color_table_size:
flags = flags | 128 # local color table flag