From 6144563d4d30d93b8e8a54406f8ba2d092127f10 Mon Sep 17 00:00:00 2001 From: passthem Date: Mon, 13 Oct 2025 11:34:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20giftool=20=E5=80=92?= =?UTF-8?q?=E6=94=BE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/docs/user/giftool.txt | 12 ++++++------ konabot/plugins/image_process/__init__.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/konabot/docs/user/giftool.txt b/konabot/docs/user/giftool.txt index 457eb74..ace78d2 100644 --- a/konabot/docs/user/giftool.txt +++ b/konabot/docs/user/giftool.txt @@ -5,17 +5,17 @@ giftool [图片] [选项] 示例 - 回复一张 GIF 并发送: - `giftool --ss 1.5 -t 2.0` + 回复一张 GIF 并发送: + `giftool --ss 1.5 -t 2.0` 从 1.5 秒处开始,截取 2 秒长度的片段。 - `giftool [图片] --ss 0:10 -to 0:15` + `giftool [图片] --ss 0:10 -to 0:15` 截取从 10 秒到 15 秒之间的片段(支持 MM:SS 或 HH:MM:SS 格式)。 - `giftool [图片] --frames:v 10` + `giftool [图片] --frames:v 10` 将整张 GIF 均匀抽帧,最终保留 10 帧。 - `giftool [图片] --ss 2 --frames:v 5` + `giftool [图片] --ss 2 --frames:v 5` 从第 2 秒开始截取,并将结果抽帧为 5 帧。 参数说明 @@ -46,7 +46,7 @@ - 若原始帧数 ≤ 指定帧数,则保留全部帧。 --s <速度>(可选) - - 调整 gif 图的速度 + - 调整 gif 图的速度。若为负数,则代表倒放 使用方式 1. 发送指令前,请确保: diff --git a/konabot/plugins/image_process/__init__.py b/konabot/plugins/image_process/__init__.py index df19ecf..010cd24 100644 --- a/konabot/plugins/image_process/__init__.py +++ b/konabot/plugins/image_process/__init__.py @@ -71,8 +71,11 @@ async def _( raise BotExceptionMessage("错误:出点时间小于入点") if frame_count is not None and frame_count <= 0: raise BotExceptionMessage("错误:帧数量应该大于 0") - if speed_factor <= 0: - raise BotExceptionMessage("错误:--speed 必须大于 0") + if speed_factor == 0: + raise BotExceptionMessage("错误:速度不能为 0") + + is_rev = speed_factor < 0 + speed_factor = abs(speed_factor) if not getattr(image, "is_animated", False): raise BotExceptionMessage("错误:输入的不是动图(GIF)") @@ -185,6 +188,10 @@ async def _( if transparency_flag: tf['transparency'] = 0 + if is_rev: + rframes = rframes[::-1] + rdur = rdur[::-1] + if rframes: rframes[0].save( output_img,