mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
♻️ 重构 pic2bytes 方法,当Image.format为空时自动回退为 PNG,并在处理 GIF 时保留所有动画帧。
This commit is contained in:
parent
27393b1e93
commit
beba7660e5
@ -510,10 +510,13 @@ class BuildImage:
|
||||
bytes: bytes
|
||||
"""
|
||||
buf = BytesIO()
|
||||
if isinstance(self.markImg.format, str) and self.markImg.format.upper() in ["GIF"]:
|
||||
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)
|
||||
return buf.getvalue()
|
||||
self.markImg.save(buf, format="PNG")
|
||||
else:
|
||||
self.markImg.save(buf, format="PNG")
|
||||
|
||||
return buf.getvalue()
|
||||
|
||||
def convert(self, type_: ModeType) -> Self:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user