Gemini Image Generation
Generate high-quality images from text prompts using Google's Gemini and Imagen models through executable scripts.
When to Use This Skill
Use this skill when you need to:
- Create visual content from text descriptions
- Generate multiple image variations
- Create images at specific resolutions (1K, 2K, 4K)
- Produce images for different aspect ratios (social media, banners, etc.)
- Generate photorealistic images or artistic visuals
- Create images with person generation controls
- Batch generate multiple images at once
- Combine with text generation for complete content creation
Available Scripts
scripts/generate_image.js
Purpose: Generate images using Gemini 3 Pro Image or Imagen 4 models
When to use:
- Any image generation task
- Multiple image generation (1-4 per request)
- Custom resolution and aspect ratio needs
- Professional asset creation
- Photorealistic or artistic image generation
Key parameters:
| Parameter |
Description |
Example |
prompt |
Text description (required) |
"A futuristic city at sunset" |
--model, -m |
Model to use |
gemini-3.1-flash-image-preview |
--output-dir, -o |
Output directory for images |
images/ |
--name, -n |
Base name for output files |
artwork |
--no-timestamp |
Disable auto timestamp |
Flag |
--aspect, -a |
Aspect ratio |
16:9 |
--size, -s |
Resolution |
2K or 4K |
--num |
Number of images (1-4) |
4 |
--person |
Person generation policy |
allow_adult |
Output: List of saved PNG file paths
Workflows
Workflow 1: Basic Image Generation
node scripts/generate_image.js "A futuristic city at sunset with flying cars"
- Best for: Quick image generation, prototypes
- Model:
gemini-3.1-flash-image-preview (default, Nano Banana 2)
- Output:
images/generated_image_YYYYMMDD_HHMMSS.png
Workflow 2: Social Media (Instagram, Facebook)
node scripts/generate_image.js "Minimalist coffee shop interior" --aspect 1:1 --size 2K --name coffee-shop
- Best for: Instagram posts, profile pictures
- Aspect: 1:1 (square format)
- Resolution: 2K (2048x2048)
- Output:
images/coffee-shop_YYYYMMDD_HHMMSS.png
Workflow 3: YouTube Thumbnails (16:9)
node scripts/generate_image.js "Tech gadget review thumbnail with vibrant colors" --aspect 16:9 --size 2K --name thumbnail
- Best for: YouTube, video thumbnails
- Aspect: 16:9 (widescreen)
- Resolution: 2K (2752x1536)
- Output:
images/thumbnail_YYYYMMDD_HHMMSS.png
Workflow 4: Multiple Variations
node scripts/generate_image.js "Abstract geometric patterns in blue and gold" --num 4 --name abstract
- Best for: A/B testing, design options
- Generates: 4 distinct variations
- Output:
images/abstract_YYYYMMDD_HHMMSS_0.png, images/abstract_YYYYMMDD_HHMMSS_1.png, etc.
Workflow 5: Custom Output Directory
node scripts/generate_image.js "Detailed architectural rendering of modern museum" --aspect 16:9 --size 4K --output-dir ./professional/ --name museum
- Best for: Print materials, high-end assets, organized projects
- Model:
gemini-3.1-flash-image-preview or gemini-3-pro-image-preview (for 4K)
- Resolution: 4K (5504x3072 for 16:9)
- Directory created automatically if it doesn't exist
Workflow 6: Photorealistic Images (Imagen 4)
node scripts/generate_image.js "Robot holding a red skateboard in urban setting" --model imagen-4.0-generate-001 --aspect 16:9 --size 2K --num 2 --name robot-skate
- Best for: Realistic photos, product shots
- Model:
imagen-4.0-generate-001 (photorealistic)
- Notes: English prompts only
- Max 4 images per request
Workflow 7: Blog Post Featured Image
node scripts/generate_image.js "Serene mountain lake at sunrise with reflections" --aspect 16:9 --size 2K --output-dir ./blog-images/ --name featured-image
- Best for: Blog headers, article images
- Combines well with: gemini-text for blog content generation
Workflow 8: Content Creation Pipeline (Text + Image)
# 1. Generate content (gemini-text skill)
node skills/gemini-text/scripts/generate.js "Write a product description for smart home device"
# 2. Generate product image (this skill)
node scripts/generate_image.js "Sleek modern smart home device on white background" --aspect 4:3 --size 2K --name product
# 3. Create social media post
- Best for: E-commerce, marketing campaigns
- Combines with: gemini-text, gemini-batch for batch production
Workflow 9: Disable Timestamp
node scripts/generate_image.js "Fixed filename image" --name my-image --no-timestamp
- Best for: When you want complete control over filename
- Output:
images/my-image.png (no timestamp)
- Use when: Generating files for specific naming schemes or automated pipelines
Parameters Reference
Model Selection
| Model |
Nickname |
Quality |
Max Size |
Best For |
gemini-3.1-flash-image-preview |
Nano Banana 2 |
Pro-level |
4K |
New default, fast + strong quality |
gemini-3-pro-image-preview |
Nano Banana Pro |
Highest |
4K |
Maximum quality and complex text rendering |
gemini-2.5-flash-image |
Nano Banana |
Good |
2K |
High-volume, low-latency |
imagen-4.0-generate-001 |
Imagen 4 |
Photorealistic |
2K |
Realistic photos, product shots |
Aspect Ratios
| Ratio |
Use Case |
1K Size |
2K Size |
| 1:1 |
Instagram, avatars |
1024x1024 |
2048x2048 |
| 16:9 |
YouTube, presentations |
1376x768 |
2752x1536 |
| 9:16 |
Instagram Stories, TikTok |
768x1376 |
1536x2752 |
| 4:3 |
Traditional displays |
1024x768 |
2048x1536 |
| 3:4 |
Portrait orientation |
768x1024 |
1536x2048 |
| 21:9 |
Ultrawide |
- |
5504x2400 |
Note: 4K resolution is available with gemini-3.1-flash-image-preview and gemini-3-pro-image-preview
Resolution Guide
| Size |
Use Case |
Best Model |
| 1K (1024px) |
Web thumbnails, previews |
Any model |
| 2K (2048px) |
Standard web, social media |
Any model |
| 4K (4096px) |
Print, high-end assets |
gemini-3-pro only |
Person Generation Policy
| Policy |
Description |
Restrictions |
dont_allow |
No people in images |
None |
allow_adult |
Adults only |
Recommended default |
allow_all |
All ages |
Restricted in EU, UK, CH, MENA |
Output Interpretation
File Naming
- Default format:
{name}_YYYYMMDD_HHMMSS.png (auto timestamp)
- Single image example:
artwork_20260130_031643.png
- Multiple images:
{name}_YYYYMMDD_HHMMSS_0.png, {name}_YYYYMMDD_HHMMSS_1.png, etc.
- Without timestamp (
--no-timestamp): {name}.png
- Script prints: "Saved: /path/to/file.png"
Image Quality
- All images include SynthID watermark for authenticity
- PNG format for lossless quality
- Can be converted to JPEG/WEBP if needed
- 4K images are significantly larger file sizes
Error Messages
- "Model not available": Check model name spelling
- "Unsupported size": Verify size/model combination
- "Aspect ratio error": Use supported ratios for selected model
Common Issues
"google-genai or pillow not installed"
cd scripts && npm install
"Image generation failed"
- Check prompt length (too verbose can fail)
- Try simpler, more focused prompts
- Verify model availability in your region
- Check API quota limits
"Unsupported aspect ratio"
- Check if ratio is supported by selected model
- Imagen 4 has fewer ratio options than Gemini
- Use 16:9 or 1:1 for best compatibility
"4K not supported"
- 4K works best with
gemini-3.1-flash-image-preview or gemini-3-pro-image-preview
- Use
--size 2K for older models
- Try
--model gemini-3.1-flash-image-preview --size 4K
"Imagen prompt language error"
- Imagen models support English prompts only
- Use
gemini-3.1-flash-image-preview for other languages
- Translate prompt to English for Imagen
File too large for storage
- Use
--size 1K for smaller files
- Compress images after generation
- Convert PNG to JPEG for web use
Best Practices
Prompt Engineering
- Be specific and descriptive
- Include style descriptors (e.g., "photorealistic", "digital art")
- Mention lighting, mood, and composition
- Use analogies for complex concepts
- Avoid negative prompts (describe what you want, not what to avoid)
Model Selection
- Use
gemini-3.1-flash-image-preview for: Best default balance, quality, speed, 4K
- Use
gemini-3-pro-image-preview for: Maximum quality, complex text rendering
- Use
gemini-2.5-flash-image for: Speed, high volume
- Use
imagen-4.0-generate-001 for: Photorealism, product shots
Performance Optimization
- Generate multiple images at once with
--num
- Use lower resolution for previews
- Batch requests for high-volume needs (gemini-batch skill)
- Cache results for repeated requests
Quality Tips
- Use 2K resolution for most web uses
- 4K only when maximum detail is needed
- Combine specific prompts with style guidance
- Test prompts with
--num 1 before generating batches
Cost Management
- Use flash models for cost efficiency
- 4K generation costs significantly more
- Batch multiple requests when possible
- Generate at 1K for testing, 2K/4K for final
Related Skills
- gemini-text: Generate text content alongside images
- gemini-tts: Create audio for image-based content
- gemini-batch: Process multiple image requests efficiently
- gemini-embeddings: Generate image embeddings for similarity search
Quick Reference
# Basic
node scripts/generate_image.js "Your prompt"
# Social media (1:1)
node scripts/generate_image.js "Prompt" --aspect 1:1 --size 2K --name social-post
# YouTube thumbnail (16:9)
node scripts/generate_image.js "Prompt" --aspect 16:9 --size 2K --name thumbnail
# 4K high quality
node scripts/generate_image.js "Prompt" --aspect 16:9 --size 4K --name high-res
# Multiple variations
node scripts/generate_image.js "Prompt" --num 4 --name variations
# Custom directory
node scripts/generate_image.js "Prompt" --output-dir ./my-images/ --name custom
# Photorealistic
node scripts/generate_image.js "Prompt" --model imagen-4.0-generate-001 --aspect 16:9 --size 2K --name photo
# No timestamp
node scripts/generate_image.js "Prompt" --name fixed-name --no-timestamp
Reference
1---2name: gemini-image3description: Generate images using Google Gemini and Imagen models via scripts/. Use for AI image generation, text-to-image, creating visuals from prompts, generating multiple images, custom aspect ratios, and high-resolution output up to 4K. Triggers on "generate image", "create image", "imagen", "text to image", "AI art", "nano banana".4license: MIT5---67# Gemini Image Generation89Generate high-quality images from text prompts using Google's Gemini and Imagen models through executable scripts.1011## When to Use This Skill1213Use this skill when you need to:14- Create visual content from text descriptions15- Generate multiple image variations16- Create images at specific resolutions (1K, 2K, 4K)17- Produce images for different aspect ratios (social media, banners, etc.)18- Generate photorealistic images or artistic visuals19- Create images with person generation controls20- Batch generate multiple images at once21- Combine with text generation for complete content creation2223## Available Scripts2425### scripts/generate_image.js26**Purpose**: Generate images using Gemini 3 Pro Image or Imagen 4 models2728**When to use**:29- Any image generation task30- Multiple image generation (1-4 per request)31- Custom resolution and aspect ratio needs32- Professional asset creation33- Photorealistic or artistic image generation3435**Key parameters**:36| Parameter | Description | Example |37|-----------|-------------|---------|38| `prompt` | Text description (required) | `"A futuristic city at sunset"` |39| `--model`, `-m` | Model to use | `gemini-3.1-flash-image-preview` |40| `--output-dir`, `-o` | Output directory for images | `images/` |41| `--name`, `-n` | Base name for output files | `artwork` |42| `--no-timestamp` | Disable auto timestamp | Flag |43| `--aspect`, `-a` | Aspect ratio | `16:9` |44| `--size`, `-s` | Resolution | `2K` or `4K` |45| `--num` | Number of images (1-4) | `4` |46| `--person` | Person generation policy | `allow_adult` |4748**Output**: List of saved PNG file paths4950## Workflows5152### Workflow 1: Basic Image Generation53```bash54node scripts/generate_image.js "A futuristic city at sunset with flying cars"55```56- Best for: Quick image generation, prototypes57- Model: `gemini-3.1-flash-image-preview` (default, Nano Banana 2)58- Output: `images/generated_image_YYYYMMDD_HHMMSS.png`5960### Workflow 2: Social Media (Instagram, Facebook)61```bash62node scripts/generate_image.js "Minimalist coffee shop interior" --aspect 1:1 --size 2K --name coffee-shop63```64- Best for: Instagram posts, profile pictures65- Aspect: 1:1 (square format)66- Resolution: 2K (2048x2048)67- Output: `images/coffee-shop_YYYYMMDD_HHMMSS.png`6869### Workflow 3: YouTube Thumbnails (16:9)70```bash71node scripts/generate_image.js "Tech gadget review thumbnail with vibrant colors" --aspect 16:9 --size 2K --name thumbnail72```73- Best for: YouTube, video thumbnails74- Aspect: 16:9 (widescreen)75- Resolution: 2K (2752x1536)76- Output: `images/thumbnail_YYYYMMDD_HHMMSS.png`7778### Workflow 4: Multiple Variations79```bash80node scripts/generate_image.js "Abstract geometric patterns in blue and gold" --num 4 --name abstract81```82- Best for: A/B testing, design options83- Generates: 4 distinct variations84- Output: `images/abstract_YYYYMMDD_HHMMSS_0.png`, `images/abstract_YYYYMMDD_HHMMSS_1.png`, etc.8586### Workflow 5: Custom Output Directory87```bash88node scripts/generate_image.js "Detailed architectural rendering of modern museum" --aspect 16:9 --size 4K --output-dir ./professional/ --name museum89```90- Best for: Print materials, high-end assets, organized projects91- Model: `gemini-3.1-flash-image-preview` or `gemini-3-pro-image-preview` (for 4K)92- Resolution: 4K (5504x3072 for 16:9)93- Directory created automatically if it doesn't exist9495### Workflow 6: Photorealistic Images (Imagen 4)96```bash97node scripts/generate_image.js "Robot holding a red skateboard in urban setting" --model imagen-4.0-generate-001 --aspect 16:9 --size 2K --num 2 --name robot-skate98```99- Best for: Realistic photos, product shots100- Model: `imagen-4.0-generate-001` (photorealistic)101- Notes: English prompts only102- Max 4 images per request103104### Workflow 7: Blog Post Featured Image105```bash106node scripts/generate_image.js "Serene mountain lake at sunrise with reflections" --aspect 16:9 --size 2K --output-dir ./blog-images/ --name featured-image107```108- Best for: Blog headers, article images109- Combines well with: gemini-text for blog content generation110111### Workflow 8: Content Creation Pipeline (Text + Image)112```bash113# 1. Generate content (gemini-text skill)114node skills/gemini-text/scripts/generate.js "Write a product description for smart home device"115116# 2. Generate product image (this skill)117node scripts/generate_image.js "Sleek modern smart home device on white background" --aspect 4:3 --size 2K --name product118119# 3. Create social media post120```121- Best for: E-commerce, marketing campaigns122- Combines with: gemini-text, gemini-batch for batch production123124### Workflow 9: Disable Timestamp125```bash126node scripts/generate_image.js "Fixed filename image" --name my-image --no-timestamp127```128- Best for: When you want complete control over filename129- Output: `images/my-image.png` (no timestamp)130- Use when: Generating files for specific naming schemes or automated pipelines131132## Parameters Reference133134### Model Selection135136| Model | Nickname | Quality | Max Size | Best For |137|-------|----------|---------|----------|----------|138| `gemini-3.1-flash-image-preview` | Nano Banana 2 | Pro-level | 4K | New default, fast + strong quality |139| `gemini-3-pro-image-preview` | Nano Banana Pro | Highest | 4K | Maximum quality and complex text rendering |140| `gemini-2.5-flash-image` | Nano Banana | Good | 2K | High-volume, low-latency |141| `imagen-4.0-generate-001` | Imagen 4 | Photorealistic | 2K | Realistic photos, product shots |142143### Aspect Ratios144145| Ratio | Use Case | 1K Size | 2K Size |146|-------|----------|----------|----------|147| 1:1 | Instagram, avatars | 1024x1024 | 2048x2048 |148| 16:9 | YouTube, presentations | 1376x768 | 2752x1536 |149| 9:16 | Instagram Stories, TikTok | 768x1376 | 1536x2752 |150| 4:3 | Traditional displays | 1024x768 | 2048x1536 |151| 3:4 | Portrait orientation | 768x1024 | 1536x2048 |152| 21:9 | Ultrawide | - | 5504x2400 |153154Note: 4K resolution is available with `gemini-3.1-flash-image-preview` and `gemini-3-pro-image-preview`155156### Resolution Guide157158| Size | Use Case | Best Model |159|------|----------|-------------|160| 1K (1024px) | Web thumbnails, previews | Any model |161| 2K (2048px) | Standard web, social media | Any model |162| 4K (4096px) | Print, high-end assets | gemini-3-pro only |163164### Person Generation Policy165166| Policy | Description | Restrictions |167|---------|-------------|----------------|168| `dont_allow` | No people in images | None |169| `allow_adult` | Adults only | Recommended default |170| `allow_all` | All ages | Restricted in EU, UK, CH, MENA |171172## Output Interpretation173174### File Naming175- Default format: `{name}_YYYYMMDD_HHMMSS.png` (auto timestamp)176- Single image example: `artwork_20260130_031643.png`177- Multiple images: `{name}_YYYYMMDD_HHMMSS_0.png`, `{name}_YYYYMMDD_HHMMSS_1.png`, etc.178- Without timestamp (`--no-timestamp`): `{name}.png`179- Script prints: "Saved: /path/to/file.png"180181### Image Quality182- All images include SynthID watermark for authenticity183- PNG format for lossless quality184- Can be converted to JPEG/WEBP if needed185- 4K images are significantly larger file sizes186187### Error Messages188- "Model not available": Check model name spelling189- "Unsupported size": Verify size/model combination190- "Aspect ratio error": Use supported ratios for selected model191192## Common Issues193194### "google-genai or pillow not installed"195```bash196cd scripts && npm install197```198199### "Image generation failed"200- Check prompt length (too verbose can fail)201- Try simpler, more focused prompts202- Verify model availability in your region203- Check API quota limits204205### "Unsupported aspect ratio"206- Check if ratio is supported by selected model207- Imagen 4 has fewer ratio options than Gemini208- Use 16:9 or 1:1 for best compatibility209210### "4K not supported"211- 4K works best with `gemini-3.1-flash-image-preview` or `gemini-3-pro-image-preview`212- Use `--size 2K` for older models213- Try `--model gemini-3.1-flash-image-preview --size 4K`214215### "Imagen prompt language error"216- Imagen models support English prompts only217- Use `gemini-3.1-flash-image-preview` for other languages218- Translate prompt to English for Imagen219220### File too large for storage221- Use `--size 1K` for smaller files222- Compress images after generation223- Convert PNG to JPEG for web use224225## Best Practices226227### Prompt Engineering228- Be specific and descriptive229- Include style descriptors (e.g., "photorealistic", "digital art")230- Mention lighting, mood, and composition231- Use analogies for complex concepts232- Avoid negative prompts (describe what you want, not what to avoid)233234### Model Selection235- Use `gemini-3.1-flash-image-preview` for: Best default balance, quality, speed, 4K236- Use `gemini-3-pro-image-preview` for: Maximum quality, complex text rendering237- Use `gemini-2.5-flash-image` for: Speed, high volume238- Use `imagen-4.0-generate-001` for: Photorealism, product shots239240### Performance Optimization241- Generate multiple images at once with `--num`242- Use lower resolution for previews243- Batch requests for high-volume needs (gemini-batch skill)244- Cache results for repeated requests245246### Quality Tips247- Use 2K resolution for most web uses248- 4K only when maximum detail is needed249- Combine specific prompts with style guidance250- Test prompts with `--num 1` before generating batches251252### Cost Management253- Use flash models for cost efficiency254- 4K generation costs significantly more255- Batch multiple requests when possible256- Generate at 1K for testing, 2K/4K for final257258## Related Skills259260- **gemini-text**: Generate text content alongside images261- **gemini-tts**: Create audio for image-based content262- **gemini-batch**: Process multiple image requests efficiently263- **gemini-embeddings**: Generate image embeddings for similarity search264265## Quick Reference266267```bash268# Basic269node scripts/generate_image.js "Your prompt"270271# Social media (1:1)272node scripts/generate_image.js "Prompt" --aspect 1:1 --size 2K --name social-post273274# YouTube thumbnail (16:9)275node scripts/generate_image.js "Prompt" --aspect 16:9 --size 2K --name thumbnail276277# 4K high quality278node scripts/generate_image.js "Prompt" --aspect 16:9 --size 4K --name high-res279280# Multiple variations281node scripts/generate_image.js "Prompt" --num 4 --name variations282283# Custom directory284node scripts/generate_image.js "Prompt" --output-dir ./my-images/ --name custom285286# Photorealistic287node scripts/generate_image.js "Prompt" --model imagen-4.0-generate-001 --aspect 16:9 --size 2K --name photo288289# No timestamp290node scripts/generate_image.js "Prompt" --name fixed-name --no-timestamp291```292293## Reference294295- See `references/` for model documentation (if available)296- Get API key: https://aistudio.google.com/apikey297- Documentation: https://ai.google.dev/gemini-api/docs/image-generation298- SynthID: https://deepmind.google/technologies/synthid/