添加 giftool 倒放选项

This commit is contained in:
2025-10-13 11:34:06 +08:00
parent a6413c9809
commit 6144563d4d
2 changed files with 15 additions and 8 deletions

View File

@ -46,7 +46,7 @@
- 若原始帧数 ≤ 指定帧数,则保留全部帧。 - 若原始帧数 ≤ 指定帧数,则保留全部帧。
--s <速度>(可选) --s <速度>(可选)
- 调整 gif 图的速度 - 调整 gif 图的速度。若为负数,则代表倒放
使用方式 使用方式
1. 发送指令前,请确保: 1. 发送指令前,请确保:

View File

@ -71,8 +71,11 @@ async def _(
raise BotExceptionMessage("错误:出点时间小于入点") raise BotExceptionMessage("错误:出点时间小于入点")
if frame_count is not None and frame_count <= 0: if frame_count is not None and frame_count <= 0:
raise BotExceptionMessage("错误:帧数量应该大于 0") raise BotExceptionMessage("错误:帧数量应该大于 0")
if speed_factor <= 0: if speed_factor == 0:
raise BotExceptionMessage("错误:--speed 必须大于 0") raise BotExceptionMessage("错误:速度不能为 0")
is_rev = speed_factor < 0
speed_factor = abs(speed_factor)
if not getattr(image, "is_animated", False): if not getattr(image, "is_animated", False):
raise BotExceptionMessage("错误输入的不是动图GIF") raise BotExceptionMessage("错误输入的不是动图GIF")
@ -185,6 +188,10 @@ async def _(
if transparency_flag: if transparency_flag:
tf['transparency'] = 0 tf['transparency'] = 0
if is_rev:
rframes = rframes[::-1]
rdur = rdur[::-1]
if rframes: if rframes:
rframes[0].save( rframes[0].save(
output_img, output_img,