[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2022-06-19 00:20:25 +00:00
parent 128ed189e5
commit f656711c80

View File

@ -824,11 +824,14 @@ def _get_optimize(im, info):
if count:
used_palette_colors.append(i)
num_palette_colors = len(im.palette.palette) // 4 if im.palette.mode == 'RGBA' else len(im.palette.palette) // 3
num_palette_colors = (
len(im.palette.palette) // 4
if im.palette.mode == "RGBA"
else len(im.palette.palette) // 3
)
# Round up to power of 2 but at least 4
num_palette_colors = max(4, 1 << (num_palette_colors - 1).bit_length())
if optimise or (
len(used_palette_colors) <= 128
and max(used_palette_colors) >= len(used_palette_colors)
or len(used_palette_colors) <= num_palette_colors // 2