SuperAPI AI Directory

slack-gif-creator

Design & creation

View repository

Updated 10-16 09:20

About this skill

Slack GIF Creator

A toolkit that provides tools and knowledge for creating animated GIFs optimized for Slack.

Slack Requirements

Size:

  • Emoji GIF: 128x128 (recommended)
  • Message GIF: 480x480

Parameters:

  • FPS: 10-30 (lower values reduce file size)
  • Colors: 48-128 (fewer colors = smaller file)
  • Duration: Emoji GIFs should be kept under 3 seconds

Core Workflow

from core.gif_builder import GIFBuilder
from PIL import Image, ImageDraw

# 1. 创建构建器
builder = GIFBuilder(width=128, height=128, fps=10)

# 2. 生成帧
for i in range(12):
    frame = Image.new('RGB', (128, 128), (240, 248, 255))
    draw = ImageDraw.Draw(frame)

    # 使用 PIL 基础图形绘制你的动画
    # (圆形、多边形、线条等)

    builder.add_frame(frame)

# 3. 保存并优化
builder.save('output.gif', num_colors=48, optimize_for_emoji=True)

Draw Graphics

Process User-Uploaded Images

If the user uploaded an image, consider that they want:

  • Direct use(e.g., "animate this", "split this into frames")
  • Use as inspiration/reference(e.g., "make something like this")

Use PIL to load and process images:

from PIL import Image

uploaded = Image.open('file.png')
# 直接使用,或仅作为颜色/风格的参考

Draw from Scratch

When drawing graphics from scratch, use PIL ImageDraw basic shapes:

from PIL import ImageDraw

draw = ImageDraw.Draw(frame)

# 圆形/椭圆
draw.ellipse([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)

# 星形、三角形、任何多边形
points = [(x1, y1), (x2, y2), (x3, y3), ...]
draw.polygon(points, fill=(r, g, b), outline=(r, g, b), width=3)

# 线条
draw.line([(x1, y1), (x2, y2)], fill=(r, g, b), width=5)

# 矩形
draw.rectangle([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)

Do not use: Emoji fonts (they render inconsistently across platforms) or assume there are pre-packaged graphics in this skill.

Make Graphics More Beautiful

Graphics should look polished and creative, not crude. Here's how:

Use thicker lines - Always set outlines and lines to width=2 or higher. Thin lines (width=1) look rough and amateurish.

Add visual depth:

  • Use gradient backgrounds (create_gradient_background)
  • Overlay multiple shapes to add complexity (e.g., a small star inside a star)

Make shapes more interesting:

  • Don't just draw a plain circle - add highlights, halos, or patterns
  • Stars can have a glow (draw a larger semi-transparent version behind them)
  • Combine multiple shapes (star + sparkle, circle + halo)

Pay attention to color schemes:

  • Use vibrant complementary colors
  • Add contrast (dark outlines for light shapes, light outlines for dark shapes)
  • Consider the overall composition

For complex shapes(hearts, snowflakes, etc.):

  • Use combinations of polygons and ellipses
  • Calculate points carefully to maintain symmetry
  • Add details (hearts can have highlight curves, snowflakes have fine branches)

Be creative and detail-oriented! A good Slack GIF should look polished, not like a placeholder graphic.

Available Tools

GIFBuilder (core.gif_builder)

Assemble frames and optimize for Slack:

builder = GIFBuilder(width=128, height=128, fps=10)
builder.add_frame(frame)  # 添加 PIL Image
builder.add_frames(frames)  # 添加帧列表
builder.save('out.gif', num_colors=48, optimize_for_emoji=True, remove_duplicates=True)

Validator (core.validators)

Check whether a GIF meets Slack requirements:

from core.validators import validate_gif, is_slack_ready

# 详细验证
passes, info = validate_gif('my.gif', is_emoji=True, verbose=True)

# 快速检查
if is_slack_ready('my.gif'):
    print("准备就绪!")

Easing Functions (core.easing)

Smooth motion instead of linear:

from core.easing import interpolate

# 进度从 0.0 到 1.0
t = i / (num_frames - 1)

# 应用缓动
y = interpolate(start=0, end=400, t=t, easing='ease_out')

# 可用:linear, ease_in, ease_out, ease_in_out,
#      bounce_out, elastic_out, back_out

Frame Helper Functions (core.frame_composer)

Convenience functions for common needs:

from core.frame_composer import (
    create_blank_frame,         # 纯色背景
    create_gradient_background,  # 垂直渐变
    draw_circle,                # 圆形辅助函数
    draw_text,                  # 简单文字渲染
    draw_star                   # 五角星
)

Animation Concepts

Shake/Vibrate

Offset an object's position with oscillation:

  • Use math.sin() or math.cos() with the frame index
  • Add small random variation for a natural feel
  • Apply to the x and/or y position

Pulse/Heartbeat

Scale the object size rhythmically:

  • Use math.sin(t * frequency * 2 * math.pi) to achieve smooth pulsing
  • For a heartbeat effect: two quick pulses then a pause (adjust the sine wave)
  • Scale between 0.8 and 1.2 times the base size

Bounce

The object falls and bounces:

  • Use interpolate() with easing='bounce_out' to achieve the landing effect
  • Use easing='ease_in' to achieve the falling (accelerating) effect
  • Simulate gravity by increasing the y velocity each frame

Rotation

Rotate the object around its center:

  • PIL:image.rotate(angle, resample=Image.BICUBIC)
  • For a swaying effect: use a sine wave to control the angle instead of linear change

Fade In/Fade Out

Gradually appear or disappear:

  • Create an RGBA image, adjust the alpha channel
  • Or use Image.blend(image1, image2, alpha)
  • Fade in: alpha from 0 to 1
  • Fade out: alpha from 1 to 0

Slide

Move the object from off-screen to a specified position:

  • Start position: outside the frame bounds
  • End position: target position
  • Use interpolate() with easing='ease_out' to achieve a smooth stop
  • For an overshoot effect: use easing='back_out'

Zoom

Scale and position to achieve a zoom effect:

  • Zoom in: scale from 0.1 to 2.0, crop the center
  • Zoom out: scale from 2.0 to 1.0
  • Motion blur can be added for a dramatic effect (PIL filter)

Explosion/Particle Burst

Create particles radiating outward:

  • Generate particles with random angles and velocities
  • Update each particle:x += vx,y += vy
  • Add gravity:vy += gravity_constant
  • Fade out particles over time (decrease alpha)

Optimization Strategies

Only when asked to reduce file size, implement the following methods:

  1. Reduce frame count - Lower the FPS (use 10 instead of 20) or shorten the duration
  2. Reduce colors - num_colors=48 instead of 128
  3. Reduce size - 128x128 instead of 480x480
  4. Remove duplicate frames - Use in save() remove_duplicates=True
  5. Emoji mode - optimize_for_emoji=True automatically optimizes
# 表情符号最大优化
builder.save(
    'emoji.gif',
    num_colors=48,
    optimize_for_emoji=True,
    remove_duplicates=True
)

Design Philosophy

This skill provides:

  • Knowledge: Slack's requirements and animation concepts
  • Tools: GIFBuilder, validators, easing functions
  • Flexibility: Create animation logic using PIL basic shapes

This skill does not provide:

  • Rigid animation templates or pre-made functions
  • Emoji font rendering (behaves inconsistently across platforms)
  • Pre-packaged graphics libraries built into the skill

Note about user uploads: This skill does not include pre-built graphics, but if the user uploads an image, use PIL to load and process it - based on their request, decide whether to use it directly or only as inspiration.

Get creative! Combine various concepts (bounce + rotation, pulse + slide, etc.) and make full use of PIL's capabilities.

Dependencies

pip install pillow imageio numpy