From cdcca6e76115dd0aa8f14606a9afa46d46f149fa Mon Sep 17 00:00:00 2001 From: HibiKier <45528451+HibiKier@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:40:05 +0800 Subject: [PATCH] Feature/buildimage.pic2bytes gif support (#1761) Co-authored-by: unknownsno <110149501+unknownsno@users.noreply.github.com> Co-authored-by: BalconyJH <73932916+BalconyJH@users.noreply.github.com> --- zhenxun/utils/_build_image.py | 8 +++++++- zhenxun/utils/typing.py | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) delete mode 100644 zhenxun/utils/typing.py diff --git a/zhenxun/utils/_build_image.py b/zhenxun/utils/_build_image.py index 83d82aea..ed16351c 100644 --- a/zhenxun/utils/_build_image.py +++ b/zhenxun/utils/_build_image.py @@ -510,7 +510,13 @@ class BuildImage: bytes: bytes """ buf = BytesIO() - self.markImg.save(buf, format="PNG") + img_format = self.markImg.format.upper() if self.markImg.format else "PNG" + + if img_format == "GIF": + self.markImg.save(buf, format="GIF", save_all=True, loop=0) + else: + self.markImg.save(buf, format="PNG") + return buf.getvalue() def convert(self, type_: ModeType) -> Self: diff --git a/zhenxun/utils/typing.py b/zhenxun/utils/typing.py deleted file mode 100644 index 8b137891..00000000 --- a/zhenxun/utils/typing.py +++ /dev/null @@ -1 +0,0 @@ -