Google Gemini Flash is a fast, efficient AI model for generating high-quality images from text descriptions. This guide covers how to use Gemini Flash for creating visual content for Trainspot projects.
Gemini 2.0 Flash is Google's latest multimodal AI model that excels at:
# Add to ~/.bashrc or ~/.zshrc
export GEMINI_API_KEY="your-api-key-here"
The easiest way to use Gemini Flash is through Claude with MCP:
{
"mcpServers": {
"gemini-flash": {
"command": "npx",
"args": ["-y", "@trainspot/gemini-mcp-server"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Once configured, simply ask Claude to generate images:
Claude, generate a professional banner image for the Belgian Beer Weekend event.
Include beer glasses, Belgian flag colors, and a festive atmosphere.
Size should be 16:9 for web use.
Claude will use Gemini Flash to generate the image and save it to your specified directory.
pip install google-generativeai pillow
import google.generativeai as genai
from PIL import Image
import os
# Configure API
genai.configure(api_key=os.environ['GEMINI_API_KEY'])
# Create model
model = genai.GenerativeModel('gemini-2.0-flash-exp')
# Generate image
prompt = """
Create a professional event poster for Belgian Beer Weekend.
Include:
- Multiple beer glasses with Belgian beers
- Belgian flag colors (black, yellow, red)
- Festive, welcoming atmosphere
- Text space at top for event title
- Modern, clean design
"""
response = model.generate_content([
prompt,
{"mime_type": "image/png"}
])
# Save image
if response.images:
image = response.images[0]
image.save('belgian_beer_weekend_poster.png')
print("Image saved successfully!")
import google.generativeai as genai
model = genai.GenerativeModel('gemini-2.0-flash-exp')
# Advanced configuration
generation_config = {
"temperature": 0.9, # Creativity (0.0-2.0)
"top_p": 0.95,
"top_k": 40,
"max_output_tokens": 8192,
}
prompt = """
Design a mobile app icon for Time Stack application:
- 1024x1024 pixels
- iOS style with rounded corners
- Clock or timecard theme
- Professional and modern
- Blue and white color scheme
- High contrast for visibility
"""
response = model.generate_content(
[prompt, {"mime_type": "image/png"}],
generation_config=generation_config
)
response.images[0].save('time_stack_icon.png')
npm install @google/generative-ai sharp
const { GoogleGenerativeAI } = require('@google/generative-ai');
const fs = require('fs');
// Initialize API
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
async function generateImage() {
const model = genAI.getGenerativeModel({
model: 'gemini-2.0-flash-exp'
});
const prompt = `
Create a professional logo for Event Stacks platform:
- Modern, tech-focused design
- Incorporate stacked elements or layers
- Blue and orange color scheme
- Suitable for app icon and web use
- Clean, scalable design
`;
const result = await model.generateContent([
{ text: prompt },
{ inlineData: { mimeType: 'image/png' } }
]);
const response = await result.response;
const imageData = response.images[0];
// Save image
fs.writeFileSync('event_stacks_logo.png', imageData);
console.log('Image generated and saved!');
}
generateImage();
prompt = """
Create a social media post image for Belgian Beer Weekend:
- Square format (1080x1080)
- Eye-catching headline space
- Beer-related imagery
- Belgian flag elements
- Instagram-optimized colors
- Professional photography style
"""
prompt = """
Design a custom illustration for empty state in POS Stack:
- Friendly, approachable style
- Shopping cart or cash register theme
- Minimalist line art
- Suitable for light and dark modes
- Centered composition
"""
prompt = """
Create an infographic showing Event Stacks architecture:
- Clean, technical diagram style
- Six app icons (Access, POS, Sales, Time, Task stacks)
- Central Event Base platform
- Connection lines showing data flow
- Professional blue color palette
- 16:9 landscape orientation
"""
prompt = """
Generate a hero image for Trainspot website:
- Event production theme
- People enjoying outdoor festival
- Professional photography style
- Warm, inviting atmosphere
- 2560x1440 resolution
- Suitable for web banner
"""
prompt = """
Create a user flow diagram illustration:
- Step-by-step process visualization
- Clean iconography
- Numbered steps
- Arrow connectors
- Light background
- Suitable for documentation
"""
✅ DO:
❌ DON'T:
Create a [type of image] for [purpose]:
Technical Requirements:
- Size: [dimensions]
- Format: [PNG/JPG/SVG]
- Aspect ratio: [16:9, 1:1, etc.]
Visual Style:
- Style: [photorealistic/illustrated/flat design]
- Colors: [color palette]
- Mood: [professional/fun/serious]
Content:
- Main elements: [list key elements]
- Text space: [if needed]
- Composition: [layout description]
Brand Guidelines:
- Align with [Trainspot/Event Stacks] branding
- Colors: [specific brand colors]
Create a mobile app splash screen for Sales Stack application:
Technical Requirements:
- Size: 1125x2436 pixels (iPhone X)
- Format: PNG with transparency
- Aspect ratio: 9:19.5 (mobile portrait)
Visual Style:
- Style: Modern, flat design with subtle gradients
- Colors: Primary blue (#2563EB), accent orange (#F59E0B), white
- Mood: Professional yet approachable
Content:
- Central app logo/icon
- Subtle background pattern or geometric shapes
- No text (text will be overlaid)
- Focus on brand recognition
Brand Guidelines:
- Align with Event Stacks design system
- Use official brand colors
- Maintain consistency with other stack apps
| Asset Type | Dimensions | Format | Use Case |
|---|---|---|---|
| Hero Banner | 2560x1440 | JPG/PNG | Website headers |
| Blog Header | 1920x1080 | JPG | Blog posts |
| Social Share | 1200x630 | JPG/PNG | Social media |
| Thumbnail | 600x400 | JPG | Preview images |
| Asset Type | iOS | Android | Format |
|---|---|---|---|
| App Icon | 1024x1024 | 512x512 | PNG |
| Splash Screen | 1125x2436 | 1080x1920 | PNG |
| Feature Graphic | - | 1024x500 | PNG |
| Screenshots | 1242x2688 | 1080x1920 | PNG |
| Asset Type | Dimensions | Format | Use Case |
|---|---|---|---|
| Instagram Post | 1080x1080 | JPG | Social media |
| Instagram Story | 1080x1920 | JPG/PNG | Stories |
| Facebook Cover | 820x312 | JPG | Cover images |
| Email Header | 600x200 | JPG/PNG | Newsletters |
import google.generativeai as genai
import os
from datetime import datetime
genai.configure(api_key=os.environ['GEMINI_API_KEY'])
model = genai.GenerativeModel('gemini-2.0-flash-exp')
# Define image requirements
image_specs = [
{
"name": "hero_banner",
"prompt": "Create a hero banner for Event Base platform...",
"size": "2560x1440"
},
{
"name": "social_media",
"prompt": "Create a social media post for Belgian Beer Weekend...",
"size": "1080x1080"
},
# Add more specifications
]
# Generate batch
output_dir = f"generated_images_{datetime.now().strftime('%Y%m%d')}"
os.makedirs(output_dir, exist_ok=True)
for spec in image_specs:
try:
response = model.generate_content([
f"{spec['prompt']}\nSize: {spec['size']}",
{"mime_type": "image/png"}
])
filename = f"{output_dir}/{spec['name']}.png"
response.images[0].save(filename)
print(f"✓ Generated: {filename}")
except Exception as e:
print(f"✗ Failed to generate {spec['name']}: {e}")
# .gitlab-ci.yml
generate_assets:
stage: build
image: python:3.11
script:
- pip install google-generativeai
- python scripts/generate_images.py
artifacts:
paths:
- generated_images/
only:
- main
✅ Technical Quality:
✅ Brand Compliance:
✅ Content Accuracy:
Solution: Increase detail in prompt and specify "high quality", "professional photography", "4K resolution"
prompt = """
Create a high-quality, professional photograph of...
- 4K resolution
- Sharp focus
- Professional lighting
- High detail
"""
Solution: Specify exact hex codes
prompt = """
Create an image using these specific colors:
- Primary: #2563EB (blue)
- Accent: #F59E0B (orange)
- Background: #FFFFFF (white)
"""
Solution: Reference existing examples or be more specific
prompt = """
Create an image in the style of modern tech company branding:
- Flat design aesthetic
- Minimal use of gradients
- Clean geometric shapes
- Similar to Apple, Google, or Stripe style
"""
✅ Save Costs:
Event Poster:
Create a vibrant event poster for Belgian Beer Weekend:
- Photorealistic beer glasses in foreground
- Belgian flag colors as background gradient
- Festive bokeh lighting effects
- Professional photography style
- 16:9 landscape format
App Icon:
Design a modern app icon for Access Stack:
- 1024x1024 square
- Centered door or access symbol
- Blue gradient background (#1E40AF to #3B82F6)
- Subtle shadow and depth
- iOS style rounded corners
Infographic:
Create a technical infographic showing app architecture:
- Clean diagram with labeled components
- Use icons for mobile apps, servers, database
- Connection lines with data flow arrows
- Professional blue and gray color scheme
- Suitable for technical documentation
Last Updated: October 2025
Maintained By: Design & Development Team