mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-28 02:46:18 +03:00
Only call _get_used_palette_colors when necessary
This commit is contained in:
parent
bf0b4cf279
commit
4df1305073
|
@ -555,12 +555,12 @@ def _get_optimize(im, info):
|
||||||
# * If we have a 'large' image, the palette is in the noise.
|
# * If we have a 'large' image, the palette is in the noise.
|
||||||
|
|
||||||
# create the new palette if not every color is used
|
# create the new palette if not every color is used
|
||||||
used_palette_colors = _get_used_palette_colors(im)
|
optimise = _FORCE_OPTIMIZE or im.mode == 'L'
|
||||||
if _FORCE_OPTIMIZE or im.mode == 'L' or \
|
if optimise or im.width * im.height < 512 * 512:
|
||||||
(len(used_palette_colors) <= 128 and
|
used_palette_colors = _get_used_palette_colors(im)
|
||||||
max(used_palette_colors) > len(used_palette_colors) and
|
if optimise or (len(used_palette_colors) <= 128 and
|
||||||
im.width * im.height < 512 * 512):
|
max(used_palette_colors) > len(used_palette_colors)):
|
||||||
return used_palette_colors
|
return used_palette_colors
|
||||||
|
|
||||||
def _get_used_palette_colors(im):
|
def _get_used_palette_colors(im):
|
||||||
used_palette_colors = []
|
used_palette_colors = []
|
||||||
|
|
Loading…
Reference in New Issue
Block a user