generating-images
Gemini APIを使用して画像を生成し、リポジトリに保存。ランディングページ、ヒーローイメージ、プロダクト画像、アバター、ダミー画像、プレースホルダー画像が必要なときに使用。画像生成、AI画像、自動生成。
When & Why to Use This Skill
This Claude skill leverages the Gemini API to automate image generation and management directly within your development repository. It streamlines the creative process by allowing users to generate high-quality visual assets—ranging from rapid prototypes to production-ready hero images—using descriptive prompts and iterative refinement workflows.
Use Cases
- Web Development: Generate high-resolution hero images and background visuals for landing pages and marketing sites.
- E-commerce: Create professional-grade product photography and mockups for digital storefronts and catalogs.
- UI/UX Design: Produce custom avatars, icons, and placeholder images to populate user interface mockups and prototypes.
- Marketing & Branding: Develop consistent visual content for social media, ads, and brand presentations using specific style guidelines.
- Iterative Prototyping: Use the 'Flash' model for quick drafts and the 'Pro' model for high-detail final assets, including editing based on reference images.
| name | generating-images |
|---|---|
| description | Gemini APIを使用して画像を生成し、リポジトリに保存。ランディングページ、ヒーローイメージ、プロダクト画像、アバター、ダミー画像、プレースホルダー画像が必要なときに使用。画像生成、AI画像、自動生成。 |
Generating Images
Generate images using Gemini API and save them to the repository.
Quick Start
# Set API key
export GEMINI_API_KEY="your-api-key"
# Generate an image (uses flash model by default)
python ~/.claude/skills/generating-images/scripts/generate_image.py \
--prompt "A modern minimalist hero image for a tech startup" \
--output "./assets/images/hero.png"
Key Concepts
Models
| Model | ID | Use Case |
|---|---|---|
| flash (default) | gemini-2.5-flash-image |
Fast, lightweight. Good for drafts and iterations |
| pro | gemini-3-pro-image-preview |
High quality. Use for final production images |
Other Settings
- Output: PNG format
- Aspect ratios:
1:1,16:9,9:16,4:3,3:4,3:2,2:3 - API Key: Environment variable
GEMINI_API_KEY
Workflows
Workflow 1: Basic Generation (Start with Flash)
- Understand user's image requirements (purpose, style, colors)
- Craft an effective prompt using guidelines below
- Generate with flash model first (fast iteration)
- Show result to user
python ~/.claude/skills/generating-images/scripts/generate_image.py \
--prompt "Your descriptive prompt here" \
--output "./path/to/image.png" \
--aspect-ratio "16:9"
Workflow 2: Quality Upgrade (Switch to Pro)
If user requests regeneration or higher quality:
python ~/.claude/skills/generating-images/scripts/generate_image.py \
--prompt "Your descriptive prompt here" \
--output "./path/to/image.png" \
--quality pro
When to switch to Pro:
- User says "make it better", "higher quality", "more detailed"
- After 2+ regeneration attempts with flash
- For final production images
- When fine details matter (text, faces, complex scenes)
Workflow 3: Edit with Reference Image
Use an existing image as a starting point:
python ~/.claude/skills/generating-images/scripts/generate_image.py \
--prompt "Add a gradient overlay and modern typography" \
--input "./reference.png" \
--output "./assets/hero-with-text.png"
Workflow 4: Iterative Refinement
- First attempt: Flash model with initial prompt
- If unsatisfied: Refine prompt, try flash again
- If still unsatisfied: Switch to pro model
- Final output: Save to appropriate location
Prompt Guidelines
Core principle: "Describe the scene, don't just list keywords."
❌ Bad: "hero image, blue, tech, modern"
✓ Good: "A modern hero image for a tech startup, featuring flowing
abstract 3D waves in electric blue gradients with soft lighting"
Prompt Structure
A [style] [type] of [subject], [action/state], set in [environment].
The [lighting] creates [mood]. [Technical details].
Quick Templates
| Use Case | Template |
|---|---|
| Hero Image | "A [mood] hero image for [purpose], featuring [elements] in [colors], [lighting], [quality]" |
| Product | "Professional product photography of [product] on [background], [lighting], [angle]" |
| Icon | "A [style] icon of [subject], [colors], [background type]" |
| Background | "A subtle [pattern] background in [colors], suitable for [use], non-distracting" |
Key Techniques
For photorealism: Use photography terms
- "85mm lens", "shallow depth of field", "three-point lighting", "golden hour"
For illustrations: Specify style explicitly
- "flat design", "minimalist", "3D rendered", "vector art", "isometric"
For quality: Add descriptors
- "commercial quality", "8K resolution", "professional", "high-end"
Detailed prompt guide: See PROMPTS.md for comprehensive examples and techniques.
Configuration
Environment Variable
| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
Yes | Google Gemini API key |
Script Options
| Option | Type | Default | Description |
|---|---|---|---|
--prompt |
string | required | Image generation prompt |
--output |
string | required | Output file path (.png) |
--input |
string | - | Reference image for editing |
--aspect-ratio |
string | 1:1 |
Image aspect ratio |
--quality |
string | flash |
Model: flash or pro |
Error Handling
API key not set:
Error: GEMINI_API_KEY environment variable is not set
→ Set it: export GEMINI_API_KEY='your-api-key'
Rate limit exceeded:
Error: Rate limit exceeded
→ Wait a few seconds and retry
Content blocked by safety filter:
Error: No image data in response
→ Modify prompt to avoid potentially sensitive content
Examples
Example 1: Landing Page Hero
# First try with flash
python ~/.claude/skills/generating-images/scripts/generate_image.py \
--prompt "A stunning hero image for a modern tech startup..." \
--output "./public/images/hero.png" \
--aspect-ratio "16:9"
# If quality insufficient, retry with pro
python ~/.claude/skills/generating-images/scripts/generate_image.py \
--prompt "A stunning hero image for a modern tech startup..." \
--output "./public/images/hero.png" \
--aspect-ratio "16:9" \
--quality pro
Example 2: Quick Placeholder
python ~/.claude/skills/generating-images/scripts/generate_image.py \
--prompt "A simple placeholder image with subtle gray geometric pattern" \
--output "./assets/placeholder.png"
Integration
After generating, add to your document:

Dependencies
pip install google-genai Pillow