From 97464fd3fc187013f6f0aa76f27eedd337612ad3 Mon Sep 17 00:00:00 2001 From: AnonymouX47 Date: Thu, 10 Mar 2022 16:29:32 +0100 Subject: [PATCH] [tui] Changed TUI animation frame caching criteria - Change: Caching of animated image frames in the TUI is now based on image file size instead of frame count. - Adresses #10. NOTE: This change is temporary and will be reverted as soon as a Pillow version including the improvements in https://github.com/python-pillow/Pillow/pull/6077 is released. --- term_img/tui/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/term_img/tui/main.py b/term_img/tui/main.py index d8bf3f9b..92ae45bf 100644 --- a/term_img/tui/main.py +++ b/term_img/tui/main.py @@ -90,7 +90,12 @@ def next_frame(*_) -> None: del image._forced_anim_size_hash frame_duration = FRAME_DURATION or image._image._frame_duration - image._animator = ImageIterator(image._image, -1, f"1.1{image._alpha}")._animator + image._animator = ImageIterator( + image._image, + -1, + f"1.1{image._alpha}", + os.stat(image._image._source).st_size <= 2097152, + )._animator # `Image.render()` checks for this. It has to be set here since `ImageIterator` # doesn't set it until the first `next()` is called.