mcpField
S
sprite-animator

sprite-animator

github.com/olafs-world创意与媒体741 次安装37 周前更新
代码仓库

关于 sprite-animator

sprite-animator 是将图像制作成循环像素艺术 GIF 的命令行工具。它使用 Gemini 生成 16 帧精灵图,并提供多种动画预设。

主要功能

  1. 01将图像制作成 GIF 动画
  2. 02使用 Gemini 生成 16 帧精灵图
  3. 03提供待机、挥手、弹跳和舞蹈预设
  4. 04为照片添加可选像素化步骤
  5. 05导出精灵图和单独帧

适用场景

  1. 01将照片制作成像素艺术角色动画
  2. 02为绘画制作待机或动作循环
  3. 03保存生成的帧以供后续编辑

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/olafs-world/sprite-animator --skill sprite-animator

安装后在 Claude Code 中输入/sprite-animator确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

pyproject.toml
.gitignore
LICENSE
README.md
uv.lock
.github/workflows/
ci.yml
sprite_animator/
cli.py
__init__.py
template.py

详细介绍

Sprite Animator

将任意图片转换为像素艺术动画 GIF。使用 Gemini 图像生成创建 16 帧精灵表,然后将其组装成循环播放的 GIF。

要求

  • 必须设置 GEMINI_API_KEY 或 GOOGLE_API_KEY 环境变量
  • 安装:uv tool install sprite-animator(或使用 uvx sprite-animator 运行一次性任务)

快速使用

# Best quality for photos — two-step converts to pixel art first, then animates
sprite-animator -i photo.png -o dance.gif -a dance --two-step -s 256 -r 2K

# From drawings or pixel art (single step is fine)
sprite-animator -i drawing.png -o idle.gif -a idle -s 256 -r 2K

动画类型

  • idle — 轻柔呼吸并眨眼(默认)
  • wave — 抬臂 → 挥手 → 回到原位
  • bounce — 蹲下 → 跳起 → 落地
  • dance — 倾斜、旋转、跳跃 — 尽情狂欢

关键选项

标志说明默认值
-i输入图片路径必填
-o输出 GIF 路径必填
-a动画类型(idle/wave/bounce/dance)idle
-s输出精灵尺寸(像素)128
-r生成分辨率(1K/2K)1K
-d帧时长(毫秒)100
--two-step先进行像素化,再制作动画(更适合照片)关闭
--keep-sheet保存原始精灵表关闭
--keep-frames保存单独的帧 PNG关闭

提示

  • 对真人照片使用 --two-step —— 否则 Gemini 会丢失人物相似度
  • 使用 -r 2K 可显著提升画质
  • 使用 -d 180 可获得更自然的播放速度(默认 100ms 较快)
  • 保存效果好的基础像素艺术精灵,以便用于不同动画
  • 在 Telegram 上将 GIF 作为文件发送,以避免转换为 MP4

Python API

from pathlib import Path
from PIL import Image
from sprite_animator.cli import ANIMATION_PRESETS, generate_sprite_sheet, create_gif, call_gemini, get_api_key
from sprite_animator.template import create_template, extract_frames

api_key = get_api_key()
preset = ANIMATION_PRESETS["dance"]

# Create template and generate sprite sheet
template = create_template(cols=4, rows=4, labels=preset["labels"])
template.save("template.png")

generate_sprite_sheet(
    api_key=api_key,
    input_image=Image.open("input.png"),
    template_path=Path("template.png"),
    output_path=Path("sheet.png"),
    prompt=preset["prompt"],
    resolution="2K",
)

# Extract frames and build GIF
frames = extract_frames(Image.open("sheet.png"), cols=4, rows=4)
create_gif(frames, Path("output.gif"), frame_duration=180, size=256)

评论

支持 Markdown