mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Minor code cleanup in GifImagePlugin
This commit is contained in:
parent
562458cdd3
commit
bf0b4cf279
|
@ -434,13 +434,10 @@ 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:
|
||||
transparent_color_exists = False
|
||||
try:
|
||||
transparency = used_palette_colors.index(transparency)
|
||||
except ValueError:
|
||||
transparent_color_exists = False
|
||||
|
||||
if "duration" in im.encoderinfo:
|
||||
duration = int(im.encoderinfo["duration"] / 10)
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user