From fe21dfa881244510284690ec6a6c928a334e2c5a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 3 Sep 2025 20:38:34 +1000 Subject: [PATCH] Simplified code --- src/PIL/AniImagePlugin.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/PIL/AniImagePlugin.py b/src/PIL/AniImagePlugin.py index 06e211373..0fdcb1d40 100644 --- a/src/PIL/AniImagePlugin.py +++ b/src/PIL/AniImagePlugin.py @@ -107,13 +107,10 @@ def _write_single_frame(im: Image.Image, fp: IO[bytes]) -> None: fp.write(icon_data) fram_end = fp.tell() - fp.seek(icon_offset - 4) - icon_size = fram_end - icon_offset - fp.write(o32(icon_size)) - - fp.seek(list_offset - 4) - list_size = fram_end - list_offset - fp.write(o32(list_size)) + for offset in (icon_offset, list_offset): + fp.seek(offset - 4) + size = fram_end - offset + fp.write(o32(size)) fp.seek(fram_end)