Communitygithub.com

Slack GIF 创建工具包

用于创建针对 Slack 优化动画 GIF 的工具包,包含大小约束验证器和可组合的动画原语。当用户请求“给我做一个在 Slack 上使用的 X 做 Y 的 GIF”时应用此技能。

Slack GIF 创建工具包 是什么?

这是一个用于创建针对 Slack 优化的动画 GIF 的工具包,主要面向开发者和 AI 智能体用户。该技能支持创建消息 GIF(最大约 2MB)和表情 GIF(最大 64KB),并提供严格的验证器以确保符合 Slack 的尺寸、帧率、颜色限制和文件大小要求。其核心包括可组合的动画原语(如抖动、弹跳、旋转、脉冲、淡入淡出、缩放、爆炸、摇摆、滑动、翻转、变形、移动和万花筒效果),这些原语可以自由组合成复杂的动画序列。此外,还提供了可选辅助工具,如 GIF 构建器(含优化选项)、文本渲染、色彩管理、视觉特效(粒子系统、闪光、冲击波)和缓动函数。该技能支持 Python,并且建议用户或智能体根据创意需求灵活应用这些工具,而不是遵循固定的操作步骤。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComposioHQ/awesome-codex-skills/tree/main/slack-gif-creator

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Slack GIF 创建器 - 灵活工具包

一个用于创建针对 Slack 优化的动画 GIF 的工具包。提供 Slack 约束验证器、可组合的动画原语以及可选的辅助工具。根据需要以任何方式应用这些工具来实现创意愿景。

Slack 的要求

Slack 对 GIF 有特定要求,具体取决于用途:

消息 GIF:

  • 最大大小:约 2MB
  • 最佳尺寸:480x480
  • 典型帧率:15-20 FPS
  • 颜色限制:128-256
  • 时长:2-5 秒

表情 GIF:

  • 最大大小:64KB(严格限制)
  • 最佳尺寸:128x128
  • 典型帧率:10-12 FPS
  • 颜色限制:32-48
  • 时长:1-2 秒

表情 GIF 具有挑战性 - 64KB 的限制非常严格。有助于解决问题的策略:

  • 总帧数限制在 10-15 帧
  • 最多使用 32-48 种颜色
  • 保持设计简洁
  • 避免渐变
  • 频繁验证文件大小

工具包结构

本技能提供三种类型的工具:

  1. 验证器 - 检查 GIF 是否符合 Slack 的要求
  2. 动画原语 - 可组合的运动构建块(抖动、弹跳、移动、万花筒)
  3. 辅助工具 - 用于常见需求的可选函数(文本、颜色、特效)

在如何应用这些工具方面拥有完全的创作自由。

核心验证器

为确保 GIF 符合 Slack 的约束,请使用这些验证器:

from core.gif_builder import GIFBuilder

# 创建 GIF 后,检查其是否符合要求
builder = GIFBuilder(width=128, height=128, fps=10)
# ... 以任何方式添加帧 ...

# 保存并检查大小
info = builder.save('emoji.gif', num_colors=48, optimize_for_emoji=True)

# save 方法会自动警告文件是否超过限制
# info 字典包含:size_kb, size_mb, frame_count, duration_seconds

文件大小验证器:

from core.validators import check_slack_size

# 检查 GIF 是否满足大小限制
passes, info = check_slack_size('emoji.gif', is_emoji=True)
# 返回:(True/False, 包含大小详情的字典)

尺寸验证器:

from core.validators import validate_dimensions

# 检查尺寸
passes, info = validate_dimensions(128, 128, is_emoji=True)
# 返回:(True/False, 包含尺寸详情的字典)

完整验证:

from core.validators import validate_gif, is_slack_ready

# 运行所有验证
all_pass, results = validate_gif('emoji.gif', is_emoji=True)

# 或快速检查
if is_slack_ready('emoji.gif', is_emoji=True):
    print("已准备好上传!")

动画原语

这些是可组合的运动构建块。以任意组合将原语应用于任何对象:

抖动

from templates.shake import create_shake_animation

# 抖动表情符号
frames = create_shake_animation(
    object_type='emoji',
    object_data={'emoji': '😱', 'size': 80},
    num_frames=20,
    shake_intensity=15,
    direction='both'  # 或 'horizontal', 'vertical'
)

弹跳

from templates.bounce import create_bounce_animation

# 弹跳圆形
frames = create_bounce_animation(
    object_type='circle',
    object_data={'radius': 40, 'color': (255, 100, 100)},
    num_frames=30,
    bounce_height=150
)

旋转

from templates.spin import create_spin_animation, create_loading_spinner

# 顺时针旋转
frames = create_spin_animation(
    object_type='emoji',
    object_data={'emoji': '🔄', 'size': 100},
    rotation_type='clockwise',
    full_rotations=2
)

# 摆动旋转
frames = create_spin_animation(rotation_type='wobble', full_rotations=3)

# 加载旋转器
frames = create_loading_spinner(spinner_type='dots')

脉冲 / 心跳

from templates.pulse import create_pulse_animation, create_attention_pulse

# 平滑脉冲
frames = create_pulse_animation(
    object_data={'emoji': '❤️', 'size': 100},
    pulse_type='smooth',
    scale_range=(0.8, 1.2)
)

# 心跳(双泵)
frames = create_pulse_animation(pulse_type='heartbeat')

# 表情 GIF 的注意脉冲
frames = create_attention_pulse(emoji='⚠️', num_frames=20)

淡入淡出

from templates.fade import create_fade_animation, create_crossfade

# 淡入
frames = create_fade_animation(fade_type='in')

# 淡出
frames = create_fade_animation(fade_type='out')

# 两个表情间的交叉淡入淡出
frames = create_crossfade(
    object1_data={'emoji': '😊', 'size': 100},
    object2_data={'emoji': '😂', 'size': 100}
)

缩放

from templates.zoom import create_zoom_animation, create_explosion_zoom

# 戏剧性放大
frames = create_zoom_animation(
    zoom_type='in',
    scale_range=(0.1, 2.0),
    add_motion_blur=True
)

# 缩小
frames = create_zoom_animation(zoom_type='out')

# 爆炸缩放
frames = create_explosion_zoom(emoji='💥')

爆炸 / 破碎

from templates.explode import create_explode_animation, create_particle_burst

# 爆发式爆炸
frames = create_explode_animation(
    explode_type='burst',
    num_pieces=25
)

# 破碎效果
frames = create_explode_animation(explode_type='shatter')

# 溶解为粒子
frames = create_explode_animation(explode_type='dissolve')

# 粒子爆发
frames = create_particle_burst(particle_count=30)

摇摆

from templates.wiggle import create_wiggle_animation, create_excited_wiggle

# 果冻摆动
frames = create_wiggle_animation(
    wiggle_type='jello',
    intensity=1.0,
    cycles=2
)

# 波浪运动
frames = create_wiggle_animation(wiggle_type='wave')

# 表情 GIF 的兴奋摇摆
frames = create_excited_wiggle(emoji='🎉')

滑动

from templates.slide import create_slide_animation, create_multi_slide

# 从左侧滑入并带有回弹
frames = create_slide_animation(
    direction='left',
    slide_type='in',
    overshoot=True
)

# 滑动穿过
frames = create_slide_animation(direction='left', slide_type='across')

# 多个对象顺序滑动
objects = [
    {'data': {'emoji': '🎯', 'size': 60}, 'direction': 'left', 'final_pos': (120, 240)},
    {'data': {'emoji': '🎪', 'size': 60}, 'direction': 'right', 'final_pos': (240, 240)}
]
frames = create_multi_slide(objects, stagger_delay=5)

翻转

from templates.flip import create_flip_animation, create_quick_flip

# 两个表情间的水平翻转
frames = create_flip_animation(
    object1_data={'emoji': '😊', 'size': 120},
    object2_data={'emoji': '😂', 'size': 120},
    flip_axis='horizontal'
)

# 垂直翻转
frames = create_flip_animation(flip_axis='vertical')

# 表情 GIF 的快速翻转
frames = create_quick_flip('👍', '👎')

变形 / 变换

from templates.morph import create_morph_animation, create_reaction_morph

# 交叉淡入淡出变形
frames = create_morph_animation(
    object1_data={'emoji': '😊', 'size': 100},
    object2_data={'emoji': '😂', 'size': 100},
    morph_type='crossfade'
)

# 缩放变形(一个缩小同时另一个变大)
frames = create_morph_animation(morph_type='scale')

# 旋转变形(类似 3D 翻转)
frames = create_morph_animation(morph_type='spin_morph')

移动效果

from templates.move import create_move_animation

# 线性移动
frames = create_move_animation(
    object_type='emoji',
    object_data={'emoji': '🚀', 'size': 60},
    start_pos=(50, 240),
    end_pos=(430, 240),
    motion_type='linear',
    easing='ease_out'
)

# 弧线移动(抛物线轨迹)
frames = create_move_animation(
    object_type='emoji',
    object_data={'emoji': '⚽', 'size': 60},
    start_pos=(50, 350),
    end_pos=(430, 350),
    motion_type='arc',
    motion_params={'arc_height': 150}
)

# 圆形移动
frames = create_move_animation(
    object_type='emoji',
    object_data={'emoji': '🌍', 'size': 50},
    motion_type='circle',
    motion_params={
        'center': (240, 240),
        'radius': 120,
        'angle_range': 360  # 完整圆
    }
)

# 波浪移动
frames = create_move_animation(
    motion_type='wave',
    motion_params={
        'wave_amplitude': 50,
        'wave_frequency': 2
    }
)

# 或使用底层缓动函数
from core.easing import interpolate, calculate_arc_motion

for i in range(num_frames):
    t = i / (num_frames - 1)
    x = interpolate(start_x, end_x, t, easing='ease_out')
    # 或: x, y = calculate_arc_motion(start, end, height, t)

万花筒效果

from templates.kaleidoscope import apply_kaleidoscope, create_kaleidoscope_animation

# 应用于单个帧
kaleido_frame = apply_kaleidoscope(frame, segments=8)

# 或创建动画万花筒
frames = create_kaleidoscope_animation(
    base_frame=my_frame,  # 或为 None 以使用演示图案
    num_frames=30,
    segments=8,
    rotation_speed=1.0
)

# 简单镜像效果(更快)
from templates.kaleidoscope import apply_simple_mirror

mirrored = apply_simple_mirror(frame, mode='quad')  # 四向镜像
# 模式: 'horizontal', 'vertical', 'quad', 'radial'

要自由组合原语,请遵循以下模式:

# 示例:弹跳 + 抖动以产生冲击效果
for i in range(num_frames):
    frame = create_blank_frame(480, 480, bg_color)

    # 弹跳运动
    t_bounce = i / (num_frames - 1)
    y = interpolate(start_y, ground_y, t_bounce, 'bounce_out')

    # 在冲击时刻添加抖动(当 y 到达地面时)
    if y >= ground_y - 5:
        shake_x = math.sin(i * 2) * 10
        x = center_x + shake_x
    else:
        x = center_x

    draw_emoji(frame, '⚽', (x, y), size=60)
    builder.add_frame(frame)

辅助工具

这些是用于常见需求的可选辅助工具。根据需要对这些工具进行使用、修改或替换为自定义实现。

GIF 构建器(组装与优化)

from core.gif_builder import GIFBuilder

# 使用所选设置创建构建器
builder = GIFBuilder(width=480, height=480, fps=20)

# 添加帧(无论您如何创建帧)
for frame in my_frames:
    builder.add_frame(frame)

# 保存并优化
builder.save('output.gif',
             num_colors=128,
             optimize_for_emoji=False)

主要特性:

  • 自动颜色量化
  • 重复帧移除
  • Slack 限制的大小警告
  • 表情模式(激进优化)

文本渲染

对于像表情这样的小型 GIF,文本可读性具有挑战性。常见解决方案涉及添加轮廓:

from core.typography import draw_text_with_outline, TYPOGRAPHY_SCALE

# 带轮廓的文本(提高可读性)
draw_text_with_outline(
    frame, "BONK!",
    position=(240, 100),
    font_size=TYPOGRAPHY_SCALE['h1'],  # 60px
    text_color=(255, 68, 68),
    outline_color=(0, 0, 0),
    outline_width=4,
    centered=True
)

要实现自定义文本渲染,请使用 PIL 的 ImageDraw.text(),这对于较大的 GIF 来说效果很好。

颜色管理

专业外观的 GIF 通常使用协调的颜色方案:

from core.color_palettes import get_palette

# 获取预置色板
palette = get_palette('vibrant')  # 或 'pastel', 'dark', 'neon', 'professional'

bg_color = palette['background']
text_color = palette['primary']
accent_color = palette['accent']

要直接使用颜色,请使用 RGB 元组 - 取决于用例的需求即可。

视觉特效

用于冲击时刻的可选特效:

from core.visual_effects import ParticleSystem, create_impact_flash, create_shockwave_rings

# 粒子系统
particles = ParticleSystem()
particles.emit_sparkles(x=240, y=200, count=15)
particles.emit_confetti(x=240, y=200, count=20)

# 每帧更新并渲染
particles.update()
particles.render(frame)

# 闪光效果
frame = create_impact_flash(frame, position=(240, 200), radius=100)

# 冲击波环
frame = create_shockwave_rings(frame, position=(240, 200), radii=[30, 60, 90])

缓动函数

平滑运动使用缓动而不是线性插值:

from core.easing import interpolate

# 物体下落(加速)
y = interpolate(start=0, end=400, t=progress, easing='ease_in')

# 物体着陆(减速)
y = interpolate(start=0, end=400, t=progress, easing='ease_out')

# 弹跳
y = interpolate(start=0, end=400, t=progress, easing='bounce_out')

# 过冲(弹性)
scale = interpolate(start=0.5, end=1.0, t=progress, easing='elastic_out')

可用的缓动类型:linear、ease_in、ease_out、ease_in_out、bounce_out、elastic_out、back_out(过冲)等,在 core/easing.py 中。

帧合成

基本绘图工具(如果需要):

from core.frame_composer import (
    create_gradient_background,  # 渐变背景
    draw_emoji_enhanced,         # 带可选阴影的表情
    draw_circle_with_shadow,     # 带深度感的形状
    draw_star                    # 五角星
)

# 渐变背景
frame = create_gradient_background(480, 480, top_color, bottom_color)

# 带阴影的表情
draw_emoji_enhanced(frame, '🎉', position=(200, 200), size=80, shadow=True)

优化策略

当 GIF 太大时:

对于消息 GIF(>2MB):

  1. 减少帧数(降低 FPS 或缩短时长)
  2. 减少颜色(128 → 64 色)
  3. 缩小尺寸(480x480 → 320x320)
  4. 启用重复帧移除

对于表情 GIF(>64KB)- 需要激进优化:

  1. 总帧数限制在 10-12 帧
  2. 最多使用 32-40 种颜色
  3. 避免渐变(纯色压缩效果更好)
  4. 简化设计(更少的元素)
  5. 在保存方法中使用 optimize_for_emoji=True

示例组合模式

简单反应(脉冲)

builder = GIFBuilder(128, 128, 10)

for i in range(12):
    frame = Image.new('RGB', (128, 128), (240, 248, 255))

    # 脉冲缩放
    scale = 1.0 + math.sin(i * 0.5) * 0.15
    size = int(60 * scale)

    draw_emoji_enhanced(frame, '😱', position=(64-size//2, 64-size//2),
                       size=size, shadow=False)
    builder.add_frame(frame)

builder.save('reaction.gif', num_colors=40, optimize_for_emoji=True)

# 验证
from core.validators import check_slack_size
check_slack_size('reaction.gif', is_emoji=True)

完整序列(表情符号入场 + 悬浮 + 闪光)

from core.gif_builder import GIFBuilder
from core.visual_effects import create_impact_flash, create_shockwave_rings
from core.easing import interpolate
from core.frame_composer import draw_emoji_enhanced

builder = GIFBuilder(480, 480, 20)
num_frames = 60

for i in range(num_frames):
    frame = Image.new('RGB', (480, 480), (20, 24, 28))
    t = i / (num_frames - 1)

    # 入场:表情从左侧飞入
    if t < 0.5:
        local_t = t / 0.5
        x = interpolate(-100, 240, local_t, easing='back_out')
        y = 240

    # 悬浮效果
    else:
        local_t = (t - 0.5) / 0.5
        x = 240 + math.sin(local_t * math.pi * 2) * 30
        y = 240 + math.sin(local_t * math.pi * 4) * 10

    draw_emoji_enhanced(frame, '🎯', position=(int(x), int(y)), size=100, shadow=True)

    if t > 0.8:
        frame = create_impact_flash(frame, position=(240, 240), radius=80)

    builder.add_frame(frame)

builder.save('sequence.gif', num_colors=128, optimize_for_emoji=False)

# 验证
from core.validators import is_slack_ready
print("Slack 准备好了!" if is_slack_ready('sequence.gif') else "需要优化")

关于 GIF 输出

本技能中的所有工具设计用于与 Python 的 PIL (Pillow) 库无缝配合。GIFBuilder 类自动处理颜色量化(颜色缩减)、重复帧移除以及 Slack 大小验证。GIF 保存后将准备用于 Slack,但始终建议使用 is_slack_ready() 函数进行双重检查,以确保符合平台的约束。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComposioHQ/-21risk-automation

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/-2chat-automation

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/ably-automation

Automate Ably tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abstract-automation

Automate Abstract tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abuselpdb-automation

Automate Abuselpdb tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abyssale-automation

Automate Abyssale tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accelo-automation

Automate Accelo tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accredible-certificates-automation

Automate Accredible Certificates tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/acculynx-automation

Automate Acculynx tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/active-campaign-automation

Automate ActiveCampaign tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/addresszen-automation

Automate Addresszen tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adobe-automation

Automate Adobe tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adrapid-automation

Automate Adrapid tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adyntel-automation

Automate Adyntel tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aeroleads-automation

Automate Aeroleads tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aero-workflow-automation

Automate Aero Workflow tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinda-automation

Automate Affinda tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinity-automation

Automate Affinity tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agencyzoom-automation

Automate Agencyzoom tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agent-deep-links

Build, validate, and troubleshoot deep links for Codex, Cursor, VS Code, Visual Studio, and similar tools. Use when users ask for clickable links (especially in Slack) that open threads, files, folders, or app settings.

相关技能