mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-28 02:46:18 +03:00
Minor code cleanup in GifImagePlugin
This commit is contained in:
parent
562458cdd3
commit
bf0b4cf279
|
@ -434,12 +434,9 @@ def _get_local_header(fp, im, offset, flags):
|
||||||
used_palette_colors = _get_optimize(im, im.encoderinfo)
|
used_palette_colors = _get_optimize(im, im.encoderinfo)
|
||||||
if used_palette_colors is not None:
|
if used_palette_colors is not None:
|
||||||
# adjust the transparency index after optimize
|
# adjust the transparency index after optimize
|
||||||
for i, palette_color in enumerate(used_palette_colors):
|
try:
|
||||||
if palette_color == transparency:
|
transparency = used_palette_colors.index(transparency)
|
||||||
transparency = i
|
except ValueError:
|
||||||
transparent_color_exists = True
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
transparent_color_exists = False
|
transparent_color_exists = False
|
||||||
|
|
||||||
if "duration" in im.encoderinfo:
|
if "duration" in im.encoderinfo:
|
||||||
|
@ -569,11 +566,9 @@ def _get_used_palette_colors(im):
|
||||||
used_palette_colors = []
|
used_palette_colors = []
|
||||||
|
|
||||||
# check which colors are used
|
# check which colors are used
|
||||||
i = 0
|
for i, count in enumerate(im.histogram()):
|
||||||
for count in im.histogram():
|
|
||||||
if count:
|
if count:
|
||||||
used_palette_colors.append(i)
|
used_palette_colors.append(i)
|
||||||
i += 1
|
|
||||||
|
|
||||||
return used_palette_colors
|
return used_palette_colors
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user