Minor code cleanup in GifImagePlugin

This commit is contained in:
Andrew Murray 2016-12-28 09:48:16 +11:00
parent 562458cdd3
commit bf0b4cf279

View File

@ -434,12 +434,9 @@ def _get_local_header(fp, im, offset, flags):
used_palette_colors = _get_optimize(im, im.encoderinfo)
if used_palette_colors is not None:
# adjust the transparency index after optimize
for i, palette_color in enumerate(used_palette_colors):
if palette_color == transparency:
transparency = i
transparent_color_exists = True
break
else:
try:
transparency = used_palette_colors.index(transparency)
except ValueError:
transparent_color_exists = False
if "duration" in im.encoderinfo:
@ -569,11 +566,9 @@ def _get_used_palette_colors(im):
used_palette_colors = []
# check which colors are used
i = 0
for count in im.histogram():
for i, count in enumerate(im.histogram()):
if count:
used_palette_colors.append(i)
i += 1
return used_palette_colors