mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
128ed189e5
commit
f656711c80
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user