Slack Gif Creator Anthropic — Slack Gif 创建器 Anthropic
v1.0.0Knowledge and utilities for creating animated GIFs 优化d for Slack. Provides constrAInts, 验证 工具s, and animation concepts. Use when users 请求 animated GIFs for Slack like "make me a GIF of X doing Y for Slack."
运行时依赖
安装命令
点击复制技能文档
Slack GIF 创建器
A 工具kit providing utilities and knowledge for creating animated GIFs 优化d for Slack.
Slack Requirements
Dimensions:
Emoji GIFs: 128x128 (recommended) Message GIFs: 480x480
Parameters:
FPS: 10-30 (lower is smaller file size) Colors: 48-128 (fewer = smaller file size) Duration: Keep under 3 seconds for emoji GIFs Core 工作流 from core.gif_构建器 导入 GIF构建器 from PIL 导入 Image, ImageDraw
# 1. 创建 构建器 构建器 = GIF构建器(width=128, height=128, fps=10)
# 2. 生成 frames for i in range(12): frame = Image.new('RGB', (128, 128), (240, 248, 255)) draw = ImageDraw.Draw(frame)
# Draw your animation using PIL primitives # (circles, polygons, lines, etc.)
构建器.添加_frame(frame)
# 3. Save with optimization 构建器.save('输出.gif', num_colors=48, 优化_for_emoji=True)
Drawing Graphics Working with User-上传ed Images
If a user 上传s an image, consider whether they want to:
Use it directly (e.g., "animate this", "split this into frames") Use it as inspiration (e.g., "make something like this")
Load and work with images using PIL:
from PIL 导入 Image
上传ed = Image.open('file.png') # Use directly, or just as reference for colors/style
Drawing from Scratch
When drawing graphics from scratch, use PIL ImageDraw primitives:
from PIL 导入 ImageDraw
draw = ImageDraw.Draw(frame)
# Circles/ovals draw.ellipse([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)
# Stars, triangles, any polygon points = [(x1, y1), (x2, y2), (x3, y3), ...] draw.polygon(points, fill=(r, g, b), outline=(r, g, b), width=3)
# Lines draw.line([(x1, y1), (x2, y2)], fill=(r, g, b), width=5)
# Rectangles draw.rectangle([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)
Don't use: Emoji fonts (unreliable across 平台s) or assume pre-packaged graphics exist in this 技能.
Making Graphics Look Good
Graphics should look polished and creative, not basic. Here's how:
Use thicker lines - Always 设置 width=2 or higher for outlines and lines. Thin lines (width=1) look choppy and amateurish.
添加 visual depth:
Use gradients for backgrounds (创建_gradient_background) Layer multiple shapes for complexity (e.g., a star with a smaller star inside)
Make shapes more interesting:
Don't just draw a plAIn circle - 添加 highlights, rings, or patterns Stars can have glows (draw larger, semi-transparent versions behind) Combine multiple shapes (stars + sparkles, circles + rings)
Pay attention to colors:
Use vibrant, complementary colors 添加 contrast (dark outlines on light shapes, light outlines on dark shapes) Consider the overall composition
For complex shapes (hearts, snowflakes, etc.):
Use combinations of polygons and ellipses Calculate points carefully for symmetry 添加 detAIls (a heart can have a highlight curve, snowflakes have intricate branches)
Be creative and detAIled! A good Slack GIF should look polished, not like placeholder graphics.
AvAIlable Utilities GIF构建器 (core.gif_构建器)
Assembles frames and 优化s for Slack:
构建器 = GIF构建器(width=128, height=128, fps=10) 构建器.添加_frame(frame) # 添加 PIL Image 构建器.添加_frames(frames) # 添加 列出 of frames 构建器.save('out.gif', num_colors=48, 优化_for_emoji=True, 移除_duplicates=True)
验证器s (core.验证器s)
检查 if GIF meets Slack requirements:
from core.验证器s 导入 验证_gif, is_slack_ready
# DetAIled 验证 passes, 信息 = 验证_gif('my.gif', is_emoji=True, verbose=True)
# Quick 检查 if is_slack_ready('my.gif'): print("Ready!")
Easing Functions (core.easing)
Smooth motion instead of linear:
from core.easing 导入 interpolate
# 进度 from 0.0 to 1.0 t = i / (num_frames - 1)
# 应用ly easing y = interpolate(启动=0, end=400, t=t, easing='ease_out')
# AvAIlable: linear, ease_in, ease_out, ease_in_out, # bounce_out, elastic_out, back_out
Frame 辅助工具s (core.frame_composer)
Convenience functions for common needs:
from core.frame_composer 导入 ( 创建_blank_frame, # Solid color background 创建_gradient_background, # Vertical gradient draw_circle, # 辅助工具 for circles draw_text, # Simple text rendering draw_star # 5-pointed star )
Animation Concepts Shake/Vibrate
Off设置 object position with oscillation:
Use math.sin() or math.cos() with frame 索引 添加 small random variations for natural feel 应用ly to x and/or y position Pulse/Heartbeat
扩展 object size rhythmically:
Use math.sin(t frequency 2 * math.pi) for smooth pulse For heartbeat: two quick pulses then 暂停 (adjust sine wave) 扩展 between 0.8 and 1.2 of base size Bounce
Object falls and bounces:
Use interpolate() with easing='bounce_out' for landing Use easing='ease_in' for falling (accelerating) 应用ly gravity by increasing y velocity each frame Spin/Rotate
Rotate object around center:
PIL: image.rotate(angle, resample=Image.BICUBIC) For wobble: use sine wa