Generate, edit, and combine game art assets using Gemini 2.5 Flash Image API. Supports sprites, backgrounds, icons, UI elements, multi-image composition, and style transfer with iOS-specific sizes (@2x/@3x).
Generate game art assets on demand using Google's Gemini 2.5 Flash Image API. Create sprites, backgrounds, app icons, and UI elements for iOS games.
GEMINI_API_KEY must be available (either in .env file or as environment variable)google-genai Python package installed (pip install google-genai)Pillow Python package for transparent backgrounds (pip install Pillow)source .venv/bin/activate && python scripts/generate_image.py generate "prompt" output_path.png
Examples:
# Character sprite with transparent background
source .venv/bin/activate && python scripts/generate_image.py generate "A cartoon knight character, side view, pixel art style" assets/sprites/knight.png --transparent
# Game background (16:9 for landscape games)
source .venv/bin/activate && python scripts/generate_image.py generate "A fantasy forest scene, vibrant colors, game background" assets/backgrounds/forest.png --aspect-ratio 16:9
# Portrait background (9:16 for portrait games)
source .venv/bin/activate && python scripts/generate_image.py generate "A vertical dungeon corridor, dark and atmospheric" assets/backgrounds/dungeon.png --aspect-ratio 9:16
# App icon (square)
source .venv/bin/activate && python scripts/generate_image.py generate "App icon for a space shooter game, bold neon colors, minimal" assets/icons/appicon.png
source .venv/bin/activate && python scripts/generate_image.py edit "prompt" input.png output.png
Examples:
# Create damage variant of a character
source .venv/bin/activate && python scripts/generate_image.py edit "Add battle damage, torn clothes, scratches" assets/sprites/knight.png assets/sprites/knight_damaged.png
# Change scene mood
source .venv/bin/activate && python scripts/generate_image.py edit "Make the scene nighttime with moonlight" assets/backgrounds/forest.png assets/backgrounds/forest_night.png
# Remove elements
source .venv/bin/activate && python scripts/generate_image.py edit "Remove the clouds, make sky clear blue" assets/backgrounds/sky.png assets/backgrounds/sky_clear.png
Combine elements from multiple images into a new image. Supports composition, style transfer, and element fusion. The Gemini API accepts up to 14 reference images (up to 6 high-fidelity objects, up to 5 human references).
source .venv/bin/activate && python scripts/generate_image.py mix "prompt" image1.png image2.png ... -o output.png
Examples:
# Combine a character with a background
source .venv/bin/activate && python scripts/generate_image.py mix \
"Place the knight character in front of the castle gate" \
assets/sprites/knight.png assets/backgrounds/castle.png \
-o assets/scenes/knight_at_castle.png
# Style transfer — apply one image's art style to another subject
source .venv/bin/activate && python scripts/generate_image.py mix \
"Redraw the character in the art style of the reference image" \
assets/sprites/hero.png assets/references/watercolor_style.png \
-o assets/sprites/hero_watercolor.png
# Combine elements from three images
source .venv/bin/activate && python scripts/generate_image.py mix \
"Create a scene with the warrior holding the sword, standing on the cliff" \
assets/sprites/warrior.png assets/items/sword.png assets/backgrounds/cliff.png \
-o assets/scenes/warrior_cliff.png --aspect-ratio 16:9
source .venv/bin/activate && python scripts/generate_image.py crop image1.png image2.png ...
Examples:
# Crop a single sprite
source .venv/bin/activate && python scripts/generate_image.py crop assets/sprites/knight.png
# Crop with padding
source .venv/bin/activate && python scripts/generate_image.py crop assets/sprites/knight.png --padding 4
# Crop all sprites
source .venv/bin/activate && python scripts/generate_image.py crop assets/sprites/*.png
| Parameter | Required | Description |
|---|---|---|
| prompt | Yes | Text description of the image to generate |
| output | Yes | Path to save the generated image |
| --aspect-ratio, -a | No | Aspect ratio (default: 1:1). Options: 1:1, 3:2, 2:3, 4:3, 3:4, 4:5, 5:4, 16:9, 9:16, 21:9 |
| --transparent, -t | No | Generate with transparent background (for sprites/icons) |
| Parameter | Required | Description |
|---|---|---|
| prompt | Yes | Text description of the edit to make |
| input | Yes | Path to the input image |
| output | Yes | Path to save the edited image |
| Parameter | Required | Description |
|---|---|---|
| prompt | Yes | Text description of how to combine the images |
| inputs | Yes | 1-14 input image paths |
| -o, --output | Yes | Path to save the combined image |
| --aspect-ratio, -a | No | Aspect ratio (default: 1:1). Options: 1:1, 3:2, 2:3, 4:3, 3:4, 4:5, 5:4, 16:9, 9:16, 21:9 |
| Parameter | Required | Description |
|---|---|---|
| images | Yes | One or more PNG image paths to crop |
| --padding, -p | No | Pixels of transparent padding to keep (default: 0) |
Generate at 1024x1024 (App Store size), then resize for device sizes:
| Size | Usage |
|---|---|
| 1024x1024 | App Store |
| 180x180 | iPhone @3x |
| 120x120 | iPhone @2x |
| 167x167 | iPad Pro @2x |
| 152x152 | iPad @2x |
Design sprites at @2x resolution, then scale for other densities:
| Design Size (points) | @1x (px) | @2x (px) | @3x (px) |
|---|---|---|---|
| 32x32 | 32x32 | 64x64 | 96x96 |
| 64x64 | 64x64 | 128x128 | 192x192 |
| 128x128 | 128x128 | 256x256 | 384x384 |
| Orientation | Device | Recommended Size |
|---|---|---|
| Landscape | iPhone | 2796x1290 (@3x) |
| Portrait | iPhone | 1290x2796 (@3x) |
| Landscape | iPad | 2732x2048 (@2x) |
Generate separate launch screen backgrounds for different device families.
The --transparent flag creates images with transparent backgrounds, ideal for game sprites.
The edit command creates consistent character variations (moods, damage states, power-ups).
edit to change only the expression/stateREF=assets/sprites/hero.png
# Idle state (reference)
source .venv/bin/activate && python scripts/generate_image.py generate \
"A cartoon hero character, standing pose, pixel art, side view" \
$REF --transparent
# Attack state
source .venv/bin/activate && python scripts/generate_image.py edit \
"Change ONLY the pose to attacking with a sword swing. Same character, same art style, same colors." \
$REF assets/sprites/hero_attack.png
# Damaged state
source .venv/bin/activate && python scripts/generate_image.py edit \
"Add battle damage, scratches, torn clothes. Same character, same art style, same pose." \
$REF assets/sprites/hero_damaged.png
# Power-up state
source .venv/bin/activate && python scripts/generate_image.py edit \
"Add a glowing golden aura around the character. Same character, same pose, same style." \
$REF assets/sprites/hero_powered.png
The mix command lets you compose new images from multiple references. This is useful for scene assembly, style transfer, and creating variations that draw from several source assets.
Combine separate sprites or assets into a single scene:
source .venv/bin/activate && python scripts/generate_image.py mix \
"Create a battle scene with the knight fighting the dragon in the forest clearing" \
assets/sprites/knight.png assets/sprites/dragon.png assets/backgrounds/forest.png \
-o assets/scenes/battle.png --aspect-ratio 16:9
Use one image as a style reference to restyle another:
# Apply watercolor style to a character
source .venv/bin/activate && python scripts/generate_image.py mix \
"Redraw this character in the art style of the reference painting. Keep the character's pose and features identical." \
assets/sprites/hero.png assets/references/watercolor_sample.png \
-o assets/sprites/hero_watercolor.png
# Match an existing game's art direction
source .venv/bin/activate && python scripts/generate_image.py mix \
"Create a new enemy character in the same art style as the reference character" \
assets/references/style_guide.png \
-o assets/sprites/new_enemy.png
--aspect-ratio flag; when omitted, defaults to 1:1# Add to .env file
echo 'GEMINI_API_KEY=your-api-key-here' >> .env
# Or export directly
export GEMINI_API_KEY="your-api-key-here"
source .venv/bin/activate && pip install google-genai Pillow