Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Creates optimized animated GIFs for Slack emoji (128x128) or messages (480x480) using Python PIL with polished drawing primitives.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: slack-gif-creator3description: Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."4license: Complete terms in LICENSE.txt5---67# Slack GIF Creator89A toolkit providing utilities and knowledge for creating animated GIFs optimized for Slack.1011## Slack Requirements1213**Dimensions:**14- Emoji GIFs: 128x128 (recommended)15- Message GIFs: 480x4801617**Parameters:**18- FPS: 10-30 (lower is smaller file size)19- Colors: 48-128 (fewer = smaller file size)20- Duration: Keep under 3 seconds for emoji GIFs2122## Core Workflow2324```python25from core.gif_builder import GIFBuilder26from PIL import Image, ImageDraw2728# 1. Create builder29builder = GIFBuilder(width=128, height=128, fps=10)3031# 2. Generate frames32for i in range(12):33frame = Image.new('RGB', (128, 128), (240, 248, 255))34draw = ImageDraw.Draw(frame)3536# Draw your animation using PIL primitives37# (circles, polygons, lines, etc.)3839builder.add_frame(frame)4041# 3. Save with optimization42builder.save('output.gif', num_colors=48, optimize_for_emoji=True)43```4445## Drawing Graphics4647### Working with User-Uploaded Images48If a user uploads an image, consider whether they want to:49- **Use it directly** (e.g., "animate this", "split this into frames")50- **Use it as inspiration** (e.g., "make something like this")5152Load and work with images using PIL:53```python54from PIL import Image5556uploaded = Image.open('file.png')57# Use directly, or just as reference for colors/style58```5960### Drawing from Scratch61When drawing graphics from scratch, use PIL ImageDraw primitives:6263```python64from PIL import ImageDraw6566draw = ImageDraw.Draw(frame)6768# Circles/ovals69draw.ellipse([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)7071# Stars, triangles, any polygon72points = [(x1, y1), (x2, y2), (x3, y3), ...]73draw.polygon(points, fill=(r, g, b), outline=(r, g, b), width=3)7475# Lines76draw.line([(x1, y1), (x2, y2)], fill=(r, g, b), width=5)7778# Rectangles79draw.rectangle([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)80```8182**Don't use:** Emoji fonts (unreliable across platforms) or assume pre-packaged graphics exist in this skill.8384### Making Graphics Look Good8586Graphics should look polished and creative, not basic. Here's how:8788**Use thicker lines** - Always set `width=2` or higher for outlines and lines. Thin lines (width=1) look choppy and amateurish.8990**Add visual depth**:91- Use gradients for backgrounds (`create_gradient_background`)92- Layer multiple shapes for complexity (e.g., a star with a smaller star inside)9394**Make shapes more interesting**:95- Don't just draw a plain circle - add highlights, rings, or patterns96- Stars can have glows (draw larger, semi-transparent versions behind)97- Combine multiple shapes (stars + sparkles, circles + rings)9899**Pay attention to colors**:100- Use vibrant, complementary colors101- Add contrast (dark outlines on light shapes, light outlines on dark shapes)102- Consider the overall composition103104**For complex shapes** (hearts, snowflakes, etc.):105- Use combinations of polygons and ellipses106- Calculate points carefully for symmetry107- Add details (a heart can have a highlight curve, snowflakes have intricate branches)108109Be creative and detailed! A good Slack GIF should look polished, not like placeholder graphics.110111## Available Utilities112113### GIFBuilder (`core.gif_builder`)114Assembles frames and optimizes for Slack:115```python116builder = GIFBuilder(width=128, height=128, fps=10)117builder.add_frame(frame) # Add PIL Image118builder.add_frames(frames) # Add list of frames119builder.save('out.gif', num_colors=48, optimize_for_emoji=True, remove_duplicates=True)120```121122### Validators (`core.validators`)123Check if GIF meets Slack requirements:124```python125from core.validators import validate_gif, is_slack_ready126127# Detailed validation128passes, info = validate_gif('my.gif', is_emoji=True, verbose=True)129130# Quick check131if is_slack_ready('my.gif'):132print("Ready!")133```134135### Easing Functions (`core.easing`)136Smooth motion instead of linear:137```python138from core.easing import interpolate139140# Progress from 0.0 to 1.0141t = i / (num_frames - 1)142143# Apply easing144y = interpolate(start=0, end=400, t=t, easing='ease_out')145146# Available: linear, ease_in, ease_out, ease_in_out,147# bounce_out, elastic_out, back_out148```149150### Frame Helpers (`core.frame_composer`)151Convenience functions for common needs:152```python153from core.frame_composer import (154create_blank_frame, # Solid color background155create_gradient_background, # Vertical gradient156draw_circle, # Helper for circles157draw_text, # Simple text rendering158draw_star # 5-pointed star159)160```161162## Animation Concepts163164### Shake/Vibrate165Offset object position with oscillation:166- Use `math.sin()` or `math.cos()` with frame index167- Add small random variations for natural feel168- Apply to x and/or y position169170### Pulse/Heartbeat171Scale object size rhythmically:172- Use `math.sin(t * frequency * 2 * math.pi)` for smooth pulse173- For heartbeat: two quick pulses then pause (adjust sine wave)174- Scale between 0.8 and 1.2 of base size175176### Bounce177Object falls and bounces:178- Use `interpolate()` with `easing='bounce_out'` for landing179- Use `easing='ease_in'` for falling (accelerating)180- Apply gravity by increasing y velocity each frame181182### Spin/Rotate183Rotate object around center:184- PIL: `image.rotate(angle, resample=Image.BICUBIC)`185- For wobble: use sine wave for angle instead of linear186187### Fade In/Out188Gradually appear or disappear:189- Create RGBA image, adjust alpha channel190- Or use `Image.blend(image1, image2, alpha)`191- Fade in: alpha from 0 to 1192- Fade out: alpha from 1 to 0193194### Slide195Move object from off-screen to position:196- Start position: outside frame bounds197- End position: target location198- Use `interpolate()` with `easing='ease_out'` for smooth stop199- For overshoot: use `easing='back_out'`200201### Zoom202Scale and position for zoom effect:203- Zoom in: scale from 0.1 to 2.0, crop center204- Zoom out: scale from 2.0 to 1.0205- Can add motion blur for drama (PIL filter)206207### Explode/Particle Burst208Create particles radiating outward:209- Generate particles with random angles and velocities210- Update each particle: `x += vx`, `y += vy`211- Add gravity: `vy += gravity_constant`212- Fade out particles over time (reduce alpha)213214## Optimization Strategies215216Only when asked to make the file size smaller, implement a few of the following methods:2172181. **Fewer frames** - Lower FPS (10 instead of 20) or shorter duration2192. **Fewer colors** - `num_colors=48` instead of 1282203. **Smaller dimensions** - 128x128 instead of 480x4802214. **Remove duplicates** - `remove_duplicates=True` in save()2225. **Emoji mode** - `optimize_for_emoji=True` auto-optimizes223224```python225# Maximum optimization for emoji226builder.save(227'emoji.gif',228num_colors=48,229optimize_for_emoji=True,230remove_duplicates=True231)232```233234## Philosophy235236This skill provides:237- **Knowledge**: Slack's requirements and animation concepts238- **Utilities**: GIFBuilder, validators, easing functions239- **Flexibility**: Create the animation logic using PIL primitives240241It does NOT provide:242- Rigid animation templates or pre-made functions243- Emoji font rendering (unreliable across platforms)244- A library of pre-packaged graphics built into the skill245246**Note on user uploads**: This skill doesn't include pre-built graphics, but if a user uploads an image, use PIL to load and work with it - interpret based on their request whether they want it used directly or just as inspiration.247248Be creative! Combine concepts (bouncing + rotating, pulsing + sliding, etc.) and use PIL's full capabilities.249250## Dependencies251252```bash253pip install pillow imageio numpy254```255