slack-gif-creator 是创建 Slack 优化 GIF 的完整工具链——4 个 Python 模块覆盖了从帧合成、动画曲线到 Slack 约束验证的完整管线。
- 🎞 GIF 构建:GIFBuilder 类,支持逐帧添加和批量操作
- 🎨 帧合成:预设的圆形、星星、渐变、文字等绘图函数
- ✅ Slack 约束验证:维度、FPS、颜色数、文件大小的自动化检查
- 📈 缓动函数:12 种动画曲线(linear、ease、bounce、elastic、back)
- 🔄 动画模式:shake、pulse、bounce、spin、fade、slide、zoom、explode
当用户请求”为 Slack 创建一个 GIF”、“做一个动画表情”、“生成一个 GIF 动画”、“make me a GIF for Slack”等时触发。
One-Line Summary
Section titled “One-Line Summary”slack-gif-creator is a complete toolchain for creating Slack-optimized animated GIFs — 4 Python modules covering the full pipeline from frame composition and animation curves to Slack constraint validation.
Core Capabilities
Section titled “Core Capabilities”- 🎞 GIF building: GIFBuilder class with frame-by-frame and batch operations
- 🎨 Frame composition: preset drawing functions (circles, stars, gradients, text)
- ✅ Slack constraint validation: automated checks for dimensions, FPS, colors, file size
- 📈 Easing functions: 12 animation curves (linear, ease, bounce, elastic, back)
- 🔄 Animation patterns: shake, pulse, bounce, spin, fade, slide, zoom, explode
Trigger Scenarios
Section titled “Trigger Scenarios”Triggers when users request “create a GIF for Slack”, “make an animated emoji”, “generate an animated GIF”, “make me a GIF for Slack”, etc.
File Inventory
Section titled “File Inventory”- slack-gif-creator
目录结构分析
Section titled “目录结构分析”slack-gif-creator 是典型的**“脚本驱动型”** Skill——4 个 Python 模块各司其职,构成完整的 GIF 创建管线。
SKILL.md 结构解析
Section titled “SKILL.md 结构解析”约 250 行的 SKILL.md 采用”知识手册 + API 参考”的混合结构:
- Slack Requirements:明确列出 Slack 的约束——Emoji: 128x128, FPS 10-30, Colors 48-128, 3 秒以内
- Core Workflow:从创建 Builder → 生成帧 → 保存优化的标准流程示例
- Drawing Graphics:PIL 绘图技巧——如何画圆、多边形、线条,如何做渐变
- Animation Concepts:8 种动画模式详解(shake, pulse, bounce, spin, fade, slide, zoom, explode)
- Optimization Strategies:5 种压缩方法
- API Reference:4 个模块的完整 API 文档
Directory Structure Analysis
Section titled “Directory Structure Analysis”slack-gif-creator is a classic “Script-driven” Skill — 4 Python modules each with clear responsibilities, forming a complete GIF creation pipeline.
SKILL.md Structure Analysis
Section titled “SKILL.md Structure Analysis”~250 line SKILL.md with a “knowledge manual + API reference” hybrid structure:
- Slack Requirements: Explicit Slack constraints — Emoji: 128x128, FPS 10-30, Colors 48-128, under 3 seconds
- Core Workflow: Standard pipeline from create Builder → generate frames → save optimized
- Drawing Graphics: PIL drawing techniques — circles, polygons, lines, gradients
- Animation Concepts: 8 animation patterns (shake, pulse, bounce, spin, fade, slide, zoom, explode)
- Optimization Strategies: 5 compression methods
- API Reference: Complete API docs for all 4 modules
Module Relationships
Section titled “Module Relationships”slack-gif-creator 模块关系图
graph TD
SKILL[SKILL.md] -->|指导| Claude
Claude -->|调用| GifBuilder[core/gif_builder.py]
Claude -->|调用| FrameComposer[core/frame_composer.py]
Claude -->|调用| Validators[core/validators.py]
Claude -->|调用| Easing[core/easing.py]
GifBuilder -->|使用| FrameComposer
GifBuilder -->|使用| Easing
GifBuilder -->|输出 GIF| File[output.gif]
Validators -->|验证| File
subgraph core [core/]
GifBuilder
FrameComposer
Validators
Easing
end
style SKILL fill:#4fc3f7,stroke:#0288d1,color:#000
style GifBuilder fill:#81c784,stroke:#388e3c,color:#000
style Validators fill:#ffb74d,stroke:#f57c00,color:#000
style File fill:#ce93d8,stroke:#7b1fa2,color:#000 Full Script Inventory
Section titled “Full Script Inventory”gif_builder.py — GIF Builder
Section titled “gif_builder.py — GIF Builder”| 脚本 | 语言 | 行数 | 复杂度 | 功能 |
|---|---|---|---|---|
gif_builder.py | Python | ~250 | ⭐⭐⭐ | GIF 构建器:帧管理、颜色量化、保存优化 |
frame_composer.py | Python | ~180 | ⭐⭐ | 帧合成工具:预置绘图函数 |
validators.py | Python | ~140 | ⭐⭐ | Slack 约束验证器:维度/大小/FPS |
easing.py | Python | ~200 | ⭐⭐ | 动画缓动函数库:12 种曲线 |
| Script | Language | Lines | Complexity | Function |
|---|---|---|---|---|
gif_builder.py | Python | ~250 | ⭐⭐⭐ | GIF Builder: frame management, color quantization, save optimization |
frame_composer.py | Python | ~180 | ⭐⭐ | Frame composition: preset drawing utilities |
validators.py | Python | ~140 | ⭐⭐ | Slack constraint validator: dimensions/size/FPS |
easing.py | Python | ~200 | ⭐⭐ | Animation easing function library: 12 curves |
frame_composer.py — 帧合成工具
Section titled “frame_composer.py — 帧合成工具”frame_composer.py 提供了绘图辅助函数——create_blank_frame(纯色背景)、create_gradient_background(垂直渐变)、draw_circle、draw_text、draw_star(五角星)。这些函数封装了 PIL ImageDraw 的常见操作,降低 Claude 在编写动画时的 cognitive load。
frame_composer.py provides drawing helper functions — create_blank_frame (solid background), create_gradient_background (vertical gradient), draw_circle, draw_text, draw_star (5-pointed star). These functions encapsulate common PIL ImageDraw operations, reducing Claude’s cognitive load when writing animations.
validators.py — Slack 约束验证
Section titled “validators.py — Slack 约束验证”validators.py 是 Slack 平台适配的”质量门”。validate_gif() 检查文件是否存在、读取维度/帧数/时长/文件大小,并根据 is_emoji 参数进行不同的验证规则。is_slack_ready() 是简化的布尔版本。
validators.py is the “quality gate” for Slack platform adaptation. validate_gif() checks file existence, reads dimensions/frame count/duration/file size, and applies different validation rules based on the is_emoji parameter. is_slack_ready() is a simplified boolean version.
easing.py — 动画缓动函数
Section titled “easing.py — 动画缓动函数”easing.py 提供了 12 种缓动函数:linear、ease_in_quad/out_quad/in_out_quad、ease_in_cubic/out_cubic/in_out_cubic、ease_in_bounce/out_bounce、ease_in_elastic/out_elastic、ease_in_back/out_back。所有函数接收 t(0.0-1.0)返回缓动后的值(0.0-1.0)。核心还有一个 interpolate() 函数用于实际插值。
easing.py provides 12 easing functions: linear, ease_in_quad/out_quad/in_out_quad, ease_in_cubic/out_cubic/in_out_cubic, ease_in_bounce/out_bounce, ease_in_elastic/out_elastic, ease_in_back/out_back. All functions take t (0.0-1.0) and return eased value (0.0-1.0). There’s also a core interpolate() function for actual interpolation.
slack-gif-creator 脚本依赖图
graph LR A[gif_builder.py] -->|import| B[easing.py] C[frame_composer.py] D[validators.py] A -->|PIL + imageio + numpy| GIF[output.gif] D -->|PIL| GIF Claude -->|调用| A Claude -->|调用| C Claude -->|调用| D Claude -->|调用| B style A fill:#81c784,stroke:#388e3c,color:#000 style B fill:#ffb74d,stroke:#f57c00,color:#000 style C fill:#4fc3f7,stroke:#0288d1,color:#000 style D fill:#ce93d8,stroke:#7b1fa2,color:#000 style GIF fill:#e0e0e0,stroke:#9e9e9e,color:#000
- 领域约束编码化:Slack 的 GIF 约束(128x128、10-30 FPS、48-128 色)被编码在 validators.py 和 SKILL.md 中,确保每次输出都符合平台要求
- 模块化架构:4 个模块职责清晰(构建/合成/验证/缓动),可以独立开发和测试
- 插值函数抽像:interpolate(start, end, t, easing) 是一个极好的 API 设计——将缓动、插值和动画逻辑分离
- 动画模式库:8 种动画模式(shake/pulse/bounce/spin 等)作为知识编码在 SKILL.md 中,而非硬编码在脚本中
- 双重品质检查:validators.py 提供程序化约束检查,SKILL.md 提供视觉品质建议(厚线条、深度层次、颜色搭配)
“如果你想为其他平台(Twitter、Discord、WhatsApp)创建媒体生成 Skill…”
- 保留模块化架构:Builder + Composer + Validator 分离是最好的起点
- 替换领域约束:在 validators.py 中替换 Slack 的维度/大小/时长限制为目标平台的限制
- 保留缓动库:easing.py 是通用的,无需修改
- 扩展合成工具:frame_composer.py 中添加目标平台特有的元素(如直接显示表情符号)
- 调整优化策略:在 gif_builder.py 中添加目标平台特定的压缩参数
⚠️ GIF 文件大小容易超标: Slack 对 GIF 大小有隐式限制(尤其是 emoji)——optimize_for_emoji 的参数组合需要仔细调整
⚠️ 色彩量化影响画质: 48 色的 GIF 看起来可能与原始设计差异很大——需要在 SKILL.md 中列出”颜色数 vs 画质”的权衡
⚠️ 帧率选择需考虑内容: 10 FPS 对快节奏动画不够,30 FPS 对慢动画浪费——没有”万能”的帧率
⚠️ 缓动函数命名需一致: SKILL.md 中使用 “bounce_out” 但在 interpolate() 中使用的是 “ease_out_bounce”——API 命名不一致可能误导 Claude
⚠️ PIL 字体不支持中文/emoji: draw_text 中使用了 ImageFont.load_default(),不支持复杂文本——需要明确告知用户限制
Design Highlights
Section titled “Design Highlights”- Domain Constraints Encoded: Slack’s GIF constraints (128x128, 10-30 FPS, 48-128 colors) encoded in validators.py and SKILL.md, ensuring every output meets platform requirements
- Modular Architecture: 4 modules with clear responsibilities (build/compose/validate/ease), independently developable and testable
- Interpolation Abstraction: interpolate(start, end, t, easing) is an excellent API design — decoupling easing, interpolation, and animation logic
- Animation Pattern Library: 8 animation patterns encoded as knowledge in SKILL.md, not hard-coded in scripts
- Dual Quality Check: validators.py provides programmatic constraint checking, SKILL.md provides visual quality guidance (thick lines, depth, color harmony)
Reusable Patterns
Section titled “Reusable Patterns”Porting Guide
Section titled “Porting Guide”“If you want to create media generation Skills for other platforms (Twitter, Discord, WhatsApp)…”
- Keep modular architecture: Builder + Composer + Validator separation is the best starting point
- Replace domain constraints: swap Slack’s dimension/size/duration limits in validators.py
- Keep easing library: easing.py is universal, no modification needed
- Extend composition tools: add platform-specific elements to frame_composer.py
- Adjust optimization strategies: add platform-specific compression parameters in gif_builder.py
Common Pitfalls
Section titled “Common Pitfalls”⚠️ GIF file size easily exceeds limits: Slack has implicit GIF size limits — optimize_for_emoji parameter combination needs careful tuning
⚠️ Color quantization affects quality: A 48-color GIF may look very different from the original design — list “color count vs quality” tradeoffs in SKILL.md
⚠️ Frame rate depends on content: 10 FPS is too slow for fast animation, 30 FPS wasteful for slow animation — no “one-size-fits-all” frame rate
⚠️ Easing function naming inconsistency: SKILL.md uses “bounce_out” but interpolate() uses “ease_out_bounce” — inconsistent API naming may mislead Claude
⚠️ PIL font doesn’t support Chinese/emoji: draw_text uses ImageFont.load_default() which doesn’t support complex text — clearly document this limitation
| 模式 | 说明 | 适用于... |
|---|---|---|
| 领域约束编码 | 将平台限制硬编码为验证函数 | 任何针对特定平台的媒体生成 skill |
| 插值抽像 | interpolate(start, end, t, easing) 统一动画 | 任何需要动画的 Python skill |
| 策略模式字典 | 用字典映射字符串到函数 | 需要多策略选择的 Python 脚本 |
| 模块化管线 | 构建/合成/验证/输出职责分离 | 任何多步骤的媒体处理 skill |
| Pattern | Description | Applies to... |
|---|---|---|
| Domain Constraints | Platform limitations hard-coded as validation functions | Any platform-specific media generation skill |
| Interpolation Abstraction | interpolate(start, end, t, easing) unified animation | Any Python skill needing animation |
| Strategy Pattern Dict | Dictionary mapping strings to functions | Python scripts needing multi-strategy selection |
| Modular Pipeline | Build/Compose/Validate/Output separation | Any multi-step media processing skill |