From f656711c80d039e60f86923b05dff4866815f2e2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 19 Jun 2022 00:20:25 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/PIL/GifImagePlugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index f58146c7e..b30ed1728 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -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