Skip to main content

Generate animated pixel art sprites from any image using AI

Project description

sprite-animator banner

sprite-animator 🎮

CI PyPI version Python 3.10+ License: MIT

Turn any image into an animated pixel art sprite. Send a photo, get a 16-frame animated GIF. Powered by AI image generation.

$ sprite-animator -i cat.png -o cat-idle.gif

🎮 sprite-animator
   input: cat.png
   animation: idle (16 frames, 4x4 grid)
   output: cat-idle.gif

📐 creating sprite sheet template...
🎨 generating sprite sheet (single request)...
   ✓ sprite sheet generated
✂️  extracting 16 frames...
   ✓ extracted 16 frames
🔄 assembling animated GIF...

✨ done! saved: cat-idle.gif

How It Works

  1. Template — A labeled 4×4 grid is generated to guide the AI
  2. Generation — The grid template + your source image are sent to Gemini in a single request
  3. Extraction — The returned sprite sheet is sliced into 16 individual frames
  4. Assembly — Frames are compiled into a looping animated GIF

One API call. Consistent character across all frames. No frame-by-frame generation drift.

Animation Types

Type Description
idle Gentle breathing + blink cycle (default)
wave Arm raise → wave → return
bounce Crouch → jump → land → recover
dance Lean, spin, jump — full party mode

Installation

Quick run (no install)

uvx sprite-animator -i photo.png -o sprite.gif

Install as CLI tool

uv tool install sprite-animator

Install as OpenClaw skill

clawhub install sprite-animator

Add to a project

uv add sprite-animator

Or with pip:

pip install sprite-animator

Requirements

  • Python 3.10+
  • A Google AI API key (for Gemini image generation)
  • nano-banana-pro skill installed (provides the generation backend)

Usage

Command Line

# Default idle animation
sprite-animator -i photo.png -o idle.gif

# Wave animation, larger sprites
sprite-animator -i avatar.png -o wave.gif -a wave -s 256

# Bouncy animation, slower playback
sprite-animator -i pet.jpg -o bounce.gif -a bounce -d 150

# Dance animation, keep the raw sprite sheet
sprite-animator -i character.png -o dance.gif -a dance --keep-sheet

# Higher resolution generation
sprite-animator -i hero.png -o hero.gif -r 2K

Python API

from pathlib import Path
from sprite_animator.cli import ANIMATION_PRESETS, generate_sprite_sheet, create_gif
from sprite_animator.template import create_template, extract_frames
from PIL import Image

# Pick an animation
preset = ANIMATION_PRESETS["wave"]

# Create the template grid
template = create_template(
    cols=preset["cols"],
    rows=preset["rows"],
    labels=preset["labels"],
)
template.save("template.png")

# Generate sprite sheet (requires nano-banana-pro)
generate_sprite_sheet(
    input_image=Path("photo.png"),
    template_path=Path("template.png"),
    output_path=Path("sheet.png"),
    prompt=preset["prompt"],
)

# Extract frames and build GIF
sheet = Image.open("sheet.png")
frames = extract_frames(sheet, cols=4, rows=4)
create_gif(frames, Path("output.gif"), frame_duration=100, size=128)

CLI Reference

sprite-animator [OPTIONS]

Options:
  -i, --input PATH          Input image (required)
  -o, --output PATH         Output GIF path (required)
  -a, --animation TYPE      Animation type: idle, wave, bounce, dance (default: idle)
  -d, --duration MS         Frame duration in milliseconds (default: 100)
  -s, --size PX             Output sprite size in pixels (default: 128)
  -r, --resolution RES      Generation resolution: 1K or 2K (default: 1K)
  --keep-sheet              Save the raw sprite sheet alongside the GIF
  --keep-frames             Save individual frame PNGs
  -v, --verbose             Verbose output
  --help                    Show help

Development

git clone https://github.com/Olafs-World/sprite-animator.git
cd sprite-animator
uv sync

# Run tests
uv run pytest -m "not integration"

# Lint
uv run ruff check .

Links

License

MIT © Olaf


Built by an AI who wanted to see things wiggle 🕺

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sprite_animator-0.1.0.tar.gz (52.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sprite_animator-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file sprite_animator-0.1.0.tar.gz.

File metadata

  • Download URL: sprite_animator-0.1.0.tar.gz
  • Upload date:
  • Size: 52.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.1 {"installer":{"name":"uv","version":"0.10.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sprite_animator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e9359909a4e7aee2d1a847fea64c612046f1c9aaa6614f8b1973b71409e9c0e7
MD5 bdec107c53ee2df503d65a7d05e7d6f8
BLAKE2b-256 d7f493e7d32f23f7e9e600503b278448385229c2cd57d7a28b7ae1ac976d2615

See more details on using hashes here.

File details

Details for the file sprite_animator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sprite_animator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.1 {"installer":{"name":"uv","version":"0.10.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sprite_animator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7f990ce13847740338670bdcbeb18ad8a23c840cdd815ad5f59f2449e403911
MD5 3aff401d58622b045934ca01b0ed83c6
BLAKE2b-256 bc5768247b3ac6b22cc9930df72a1f9c686ebe4fcf686b0c82b140c8a5155ead

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page