batch-image-generator
Batch generate game assets from a JSON manifest file. Supports mother images, variants, background removal, and organized output directories. Wraps text-to-image, generate-image-by-image, and backgrou
SKILL.md.codebuddy/skills/batch-image-generator/SKILL.md
GitHubBatch Image Generator
Overview
Batch generate game assets from a structured JSON manifest file. This skill orchestrates multiple image generation skills (text-to-image, generate-image-by-image, background-remover) to produce complete asset sets in one automated run.
When to Use This Skill
Use this skill when:
- Generating multiple game assets at once (characters, UI, backgrounds, effects)
- Need consistent style across all assets
- Want automated variant generation (hover/pressed states, animation frames)
- Require organized output with proper directory structure
Quick Start
Basic Usage
python3 scripts/batch_generate.py manifest.json
With Options
# Dry run (show what would be generated)
python3 scripts/batch_generate.py manifest.json --dry-run
# Skip background removal for all assets
python3 scripts/batch_generate.py manifest.json --skip-remove-bg
# Custom output directory
python3 scripts/batch_generate.py manifest.json --output-dir ./assets
# Resume from a specific asset (skip already generated)
python3 scripts/batch_generate.py manifest.json --resume-from "animal_fox_01"
# Verbose output
python3 scripts/batch_generate.py manifest.json --verbose
Manifest File Format
The manifest is a JSON file defining all assets to generate:
{
"config": {
"style": "Q版卡通风格,可爱萌系,大头小身比例2:1,...",
"default_size": "1024x1024",
"default_quality": "high",
"temp_dir": "./temp",
"skills_dir": ".codebuddy/skills"
},
"assets": [
{
"id": "animal_panda_01",
"type": "mother",
"prompt": "可爱的Q版小熊猫,正面视角,...",
"output": "images/characters/animal_panda_01.png",
"size": "1024x1024",
"quality": "high",
"remove_bg": true
},
{
"id": "animal_panda_02",
"type": "variant",
"mother_id": "animal_panda_01",
"edit_prompt": "same pose, eyes closed, blinking, peaceful expression",
"output": "images/characters/animal_panda_02.png",
"strength": 0.5,
"remove_bg": true
},
{
"id": "bg_sky",
"type": "mother",
"prompt": "梦幻天空背景,淡蓝到白色渐变,...",
"output": "images/environments/bg_sky.png",
"size": "1408x640",
"remove_bg": false
}
]
}
Config Section
| Field | Type | Required | Description |
|---|---|---|---|
style |
string | Yes | Global style prompt prepended to all generation prompts |
default_size |
string | No | Default image size (default: "1024x1024") |
default_quality |
string | No | Default quality level: low/medium/high (default: "high") |
temp_dir |
string | No | Temporary directory for intermediate files (default: "./temp") |
skills_dir |
string | No | Path to skills directory (default: ".codebuddy/skills") |
Asset Types
Mother Image (type: "mother")
Base image generated from text prompt.
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | Unique identifier for this asset |
type |
string | Yes | Must be "mother" |
prompt |
string | Yes | Text description (style will be prepended) |
output |
string | Yes | Output file path relative to output_dir |
size |
string | No | Image size (uses config.default_size if not set) |
quality |
string | No | Quality level (uses config.default_quality if not set) |
remove_bg |
boolean | No | Whether to remove background (default: true) |
background |
string | No | "transparent" or "opaque" (for text-to-image) |
Variant Image (type: "variant")
Image generated by editing a mother image.
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | Unique identifier for this asset |
type |
string | Yes | Must be "variant" |
mother_id |
string | Yes | ID of the mother image to base this on |
edit_prompt |
string | Yes | Edit instruction for the variant |
output |
string | Yes | Output file path relative to output_dir |
strength |
float | No | Edit strength 0.0-1.0 (default: 0.5) |
remove_bg |
boolean | No | Whether to remove background (default: true) |
Example Manifests
Game Characters with Animation Frames
{
"config": {
"style": "Q版卡通风格,可爱萌系,游戏美术资源",
"default_size": "1024x1024",
"default_quality": "high"
},
"assets": [
{
"id": "hero_idle_01",
"type": "mother",
"prompt": "勇敢的Q版小骑士,正面站立,手持小剑盾牌,isolated on white",
"output": "characters/hero_idle_01.png"
},
{
"id": "hero_idle_02",
"type": "variant",
"mother_id": "hero_idle_01",
"edit_prompt": "same character, eyes blinking, slight breath movement",
"output": "characters/hero_idle_02.png",
"strength": 0.3
},
{
"id": "hero_walk_01",
"type": "variant",
"mother_id": "hero_idle_01",
"edit_prompt": "same character, left foot forward, walking pose",
"output": "characters/hero_walk_01.png",
"strength": 0.5
}
]
}
UI Elements with States
{
"config": {
"style": "木质游戏UI,温暖棕色调,圆角设计",
"default_size": "512x512"
},
"assets": [
{
"id": "btn_play_normal",
"type": "mother",
"prompt": "游戏开始按钮,木质质感,3D立体效果,isolated",
"output": "ui/btn_play_normal.png"
},
{
"id": "btn_play_hover",
"type": "variant",
"mother_id": "btn_play_normal",
"edit_prompt": "same button, slightly brighter, glow effect",
"output": "ui/btn_play_hover.png",
"strength": 0.3
},
{
"id": "btn_play_pressed",
"type": "variant",
"mother_id": "btn_play_normal",
"edit_prompt": "same button, pressed down, darker shadow",
"output": "ui/btn_play_pressed.png",
"strength": 0.4
}
]
}
Backgrounds (No BG Removal)
{
"config": {
"style": "梦幻插画风格,柔和光影",
"default_size": "1408x640"
},
"assets": [
{
"id": "bg_forest",
"type": "mother",
"prompt": "神秘森林场景,层叠树木,阳光透过树冠",
"output": "backgrounds/bg_forest.png",
"remove_bg": false
},
{
"id": "bg_forest_night",
"type": "variant",
"mother_id": "bg_forest",
"edit_prompt": "same scene, night time, moonlight, fireflies",
"output": "backgrounds/bg_forest_night.png",
"strength": 0.6,
"remove_bg": false
}
]
}
VFX Particles (Black Background)
{
"config": {
"style": "game vfx particle, centered",
"default_size": "512x512"
},
"assets": [
{
"id": "particle_star",
"type": "mother",
"prompt": "golden star particle, bright glow, isolated on solid black background",
"output": "effects/particle_star.png",
"remove_bg": false
},
{
"id": "particle_sparkle",
"type": "mother",
"prompt": "white sparkle particle, starburst shape, isolated on solid black background",
"output": "effects/particle_sparkle.png",
"remove_bg": false
}
]
}
CLI Parameters
| Parameter | Short | Description |
|---|---|---|
manifest |
Path to JSON manifest file (required) | |
--output-dir |
-o |
Base output directory (default: current dir) |
--dry-run |
-d |
Show what would be generated without executing |
--skip-remove-bg |
Skip background removal for all assets | |
--resume-from |
-r |
Resume from specified asset ID (skip previous) |
--verbose |
-v |
Show detailed progress and debug info |
--parallel |
-p |
Number of parallel workers (default: 1, sequential) |
Output
The script produces:
- Generated assets in the specified output paths
- Temp files in the temp directory (can be cleaned up)
- Progress log showing completion status
- Summary report at the end with success/failure counts
Example output:
🎨 Batch Image Generator
========================
📋 Manifest: game_assets.json
📁 Output: ./assets
🎯 Total assets: 15
[1/15] 🖼️ Generating mother: animal_panda_01
✅ Generated: images/characters/animal_panda_01.png
[2/15] 🔄 Generating variant: animal_panda_02
✅ Generated: images/characters/animal_panda_02.png
...
========================
✅ Completed: 15/15
⏱️ Total time: 12m 34s
📁 Output directory: ./assets
Error Handling
- If a generation fails, the script logs the error and continues with the next asset
- Use
--resume-fromto restart from a failed asset after fixing issues - Failed assets are listed in the summary report
- Temp files are preserved for debugging (clean manually if needed)
Best Practices
Manifest Organization
- Group by category: Put related assets together (all characters, then UI, then backgrounds)
- Mother before variants: Always define mother images before their variants
- Consistent naming: Use clear naming convention (e.g.,
category_name_state.png)
Performance Tips
- Sequential execution: API doesn't support parallel calls, so assets are generated one by one
- Resume support: Use
--resume-fromto continue interrupted batches - Dry run first: Use
--dry-runto validate manifest before actual generation
Style Consistency
- Global style in config: Define common style elements in
config.style - Asset-specific details: Put unique details in each asset's
prompt - Variant consistency: Use similar
strengthvalues for related variants
Dependencies
This skill requires the following skills to be available:
text-to-image- For generating mother imagesgenerate-image-by-image- For generating variantsbackground-remover- For removing backgrounds
Install Python dependencies:
pip install requests Pillow rembg
Files in This Skill
SKILL.md- This documentationscripts/batch_generate.py- Main batch generation script