feat: add --pingpong flag to giftool #64

Merged
Passthem merged 1 commits from pi-agent/konabot:feat/giftool-pingpong into master 2026-04-02 20:17:27 +08:00
Contributor

User description

Summary

Add pingpong mode to giftool command. When --pingpong flag is used, the generated GIF will play forward then backward, creating a back-and-forth looping effect.

Changes

  • Add --pingpong option to giftool command
  • Support combining with --speed for adjusted playback speed
  • Update documentation with new option

Usage Examples

  • giftool [图片] --pingpong
  • giftool [图片] --pingpong --speed 2.0

Testing

  • All existing tests pass
  • Plugin loads successfully

PR Type

Enhancement


Description

  • giftool 命令添加 --pingpong 乒乓模式

  • 支持正放-倒放往复循环效果

  • 可与 --speed 参数组合使用

  • 更新用户文档说明新功能


Diagram Walkthrough

flowchart LR
  A["原始帧序列"] --> B["应用 --pingpong"]
  B --> C["正向帧"]
  B --> D["反向帧(去重)"]
  C --> E["拼接输出"]
  D --> E
  E --> F["往复循环 GIF"]

File Walkthrough

Relevant files
Enhancement
__init__.py
实现 pingpong 模式的帧序列处理                                                                         

konabot/plugins/image_process/init.py

  • 添加 pingpong 模式处理逻辑
  • 复制并反转帧序列(去除首帧避免重复)
  • 拼接正向和反向帧及其持续时间
+12/-0   
Documentation
giftool.txt
添加 pingpong 参数的用户文档                                                                           

konabot/docs/user/giftool.txt

  • 新增 --pingpong 参数说明文档
  • 描述乒乓模式的功能和效果
  • 提供使用示例和参数组合说明
+8/-0     

### **User description** ## Summary Add pingpong mode to giftool command. When --pingpong flag is used, the generated GIF will play forward then backward, creating a back-and-forth looping effect. ## Changes - Add --pingpong option to giftool command - Support combining with --speed for adjusted playback speed - Update documentation with new option ## Usage Examples - `giftool [图片] --pingpong` - `giftool [图片] --pingpong --speed 2.0` ## Testing - All existing tests pass - Plugin loads successfully ___ ### **PR Type** Enhancement ___ ### **Description** - 为 `giftool` 命令添加 `--pingpong` 乒乓模式 - 支持正放-倒放往复循环效果 - 可与 `--speed` 参数组合使用 - 更新用户文档说明新功能 ___ ### Diagram Walkthrough ```mermaid flowchart LR A["原始帧序列"] --> B["应用 --pingpong"] B --> C["正向帧"] B --> D["反向帧(去重)"] C --> E["拼接输出"] D --> E E --> F["往复循环 GIF"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>__init__.py</strong><dd><code>实现 pingpong 模式的帧序列处理</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> konabot/plugins/image_process/__init__.py - 添加 `pingpong` 模式处理逻辑 - 复制并反转帧序列(去除首帧避免重复) - 拼接正向和反向帧及其持续时间 </details> </td> <td><a href="https://gitea.service.jazzwhom.top/mttu-developers/konabot/src/branch/feat/giftool-pingpong/konabot/plugins/image_process/__init__.py">+12/-0</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Documentation</strong></td><td><table> <tr> <td> <details> <summary><strong>giftool.txt</strong><dd><code>添加 pingpong 参数的用户文档</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> konabot/docs/user/giftool.txt - 新增 `--pingpong` 参数说明文档 - 描述乒乓模式的功能和效果 - 提供使用示例和参数组合说明 </details> </td> <td><a href="https://gitea.service.jazzwhom.top/mttu-developers/konabot/src/branch/feat/giftool-pingpong/konabot/docs/user/giftool.txt">+8/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___
pi-agent added 1 commit 2026-04-02 20:07:23 +08:00
Add pingpong mode to giftool command. When --pingpong flag is used,
the generated GIF will play forward then backward, creating a
back-and-forth looping effect.

Features:
- Add --pingpong option to giftool command
- Support combining with --speed for adjusted playback speed
- Update documentation with new option

Examples:
- giftool [图片] --pingpong
- giftool [图片] --pingpong --speed 2.0
Collaborator

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵
🧪 No relevant tests
🔒 No security concerns identified
 Recommended focus areas for review

逻辑问题

pingpongis_rev 同时启用时,可能产生非预期行为。代码先反转帧序列(第164-165行),然后再应用 pingpong 模式(第168-175行),这可能导致混乱的播放顺序。建议明确这两个选项的交互逻辑或互斥处理。

if is_rev:
    rframes = rframes[::-1]
    rdur_ms = rdur_ms[::-1]

# 处理 pingpong 模式
if pingpong:
    # 复制一份反转的帧序列(去掉第一帧避免重复)
    pingpong_frames = rframes[1:][::-1] if len(rframes) > 1 else rframes[::-1]
    pingpong_durations = rdur_ms[1:][::-1] if len(rdur_ms) > 1 else rdur_ms[::-1]

    # 拼接正放和倒放
    rframes = rframes + pingpong_frames
    rdur_ms = rdur_ms + pingpong_durations
边界情况

rframes 只有1帧时,第170行的切片逻辑 rframes[1:][::-1] 会返回空列表,导致 pingpong 模式实际上不生效。虽然有 else 分支处理,但这种情况下 pingpong 效果可能不符合用户预期。

pingpong_frames = rframes[1:][::-1] if len(rframes) > 1 else rframes[::-1]
pingpong_durations = rdur_ms[1:][::-1] if len(rdur_ms) > 1 else rdur_ms[::-1]
## PR Reviewer Guide 🔍 Here are some key observations to aid the review process: <table> <tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 2 🔵🔵⚪⚪⚪</td></tr> <tr><td>🧪&nbsp;<strong>No relevant tests</strong></td></tr> <tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr> <tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br> <details><summary><a href='https://gitea.service.jazzwhom.top/mttu-developers/konabot/src/branch/feat/giftool-pingpong/konabot/plugins/image_process/__init__.py#L163-L175'><strong>逻辑问题</strong></a> 当 `pingpong` 和 `is_rev` 同时启用时,可能产生非预期行为。代码先反转帧序列(第164-165行),然后再应用 pingpong 模式(第168-175行),这可能导致混乱的播放顺序。建议明确这两个选项的交互逻辑或互斥处理。 </summary> ```python if is_rev: rframes = rframes[::-1] rdur_ms = rdur_ms[::-1] # 处理 pingpong 模式 if pingpong: # 复制一份反转的帧序列(去掉第一帧避免重复) pingpong_frames = rframes[1:][::-1] if len(rframes) > 1 else rframes[::-1] pingpong_durations = rdur_ms[1:][::-1] if len(rdur_ms) > 1 else rdur_ms[::-1] # 拼接正放和倒放 rframes = rframes + pingpong_frames rdur_ms = rdur_ms + pingpong_durations ``` </details> <details><summary><a href='https://gitea.service.jazzwhom.top/mttu-developers/konabot/src/branch/feat/giftool-pingpong/konabot/plugins/image_process/__init__.py#L170-L171'><strong>边界情况</strong></a> 当 `rframes` 只有1帧时,第170行的切片逻辑 `rframes[1:][::-1]` 会返回空列表,导致 pingpong 模式实际上不生效。虽然有 `else` 分支处理,但这种情况下 pingpong 效果可能不符合用户预期。 </summary> ```python pingpong_frames = rframes[1:][::-1] if len(rframes) > 1 else rframes[::-1] pingpong_durations = rdur_ms[1:][::-1] if len(rdur_ms) > 1 else rdur_ms[::-1] ``` </details> </td></tr> </table>
Collaborator

Failed to generate code suggestions for PR

Failed to generate code suggestions for PR
Passthem merged commit f7212d6f67 into master 2026-04-02 20:17:27 +08:00
Sign in to join this conversation.
No description provided.