Get the FREE Ultimate OpenClaw Setup Guide →

gemini-image-gen

npx machina-cli add skill jezweb/claude-skills/gemini-image-gen --openclaw
Files (1)
SKILL.md
4.3 KB

Gemini Image Generator

Generate contextual images for web projects using the Gemini API. Produces hero backgrounds, OG cards, placeholder photos, textures, and style-matched variants.

Setup

API Key: Set GEMINI_API_KEY as an environment variable. Get a key from https://aistudio.google.com/apikey if you don't have one.

export GEMINI_API_KEY="your-key-here"

Workflow

Step 1: Understand What's Needed

Gather from the user or project context:

  • What: hero background, product photo, texture, OG image, placeholder
  • Style: warm/cool/minimal/luxurious/bold — check project's colour palette (input.css, tailwind config)
  • Dimensions: hero (1920x1080), OG (1200x630), square (1024x1024), custom
  • Count: single image or multiple variants to choose from

Step 2: Build the Prompt

Use concrete photography parameters, not abstract adjectives. Read references/prompting-guide.md for the full framework.

Quick rules:

  • Narrate like directing a photographer
  • Use camera specs: "85mm f/1.8", "wide angle 24mm"
  • Use colour anchors from the project palette: "warm terracotta (#C66A52) and cream (#F5F0EB) tones"
  • Use lighting descriptions: "golden-hour light from the left, 4500K"
  • Always end with: "No text, no watermarks, no logos, no hands"

Step 3: Generate

Generate a Python script (no dependencies beyond stdlib) that calls the Gemini API. The script should:

  1. Read GEMINI_API_KEY from environment
  2. POST to https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent
  3. Include "responseModalities": ["TEXT", "IMAGE"] in generationConfig
  4. Parse the response: extract inlineData.data (base64) from candidate parts
  5. Decode base64 and save as PNG
  6. Support multiple variants (generate N times, save as name-1.png, name-2.png)

For style matching with a reference image, include the reference as an inlineData part before the text prompt, and use temperature 0.7 (instead of 1.0).

See references/api-pattern.md for the full implementation pattern including error handling and response parsing.

Critical: Never pass prompts via curl + bash arguments — shell escaping breaks on apostrophes. Always use Python's json.dumps() or write the prompt to a file first.

Step 4: Post-Process (Optional)

Use the image-processing skill for resizing, format conversion, or optimisation.

Step 5: Present to User

Show the generated images for review. Read the image files to display them inline if possible, otherwise describe what was generated and let the user open them.

Presets

Starting prompts — enhance with project-specific context (colours, mood, subject):

PresetBase Prompt
hero-background"Wide atmospheric background, soft-focus, [colour tones], [mood], landscape 1920x1080"
og-image"Clean branded card background, [brand colours], subtle gradient, 1200x630"
placeholder-photo"Professional stock-style photo of [subject], natural lighting, warm tones"
texture-pattern"Subtle repeating texture, [material], seamless tile, muted [colour]"
product-shot"Product photography, [item] on [surface], soft studio lighting, clean background"

Model Selection

Use caseModelCost
Drafts, quick placeholdersgemini-2.5-flash-imageFree (~500/day)
Final client assetsgemini-3-pro-image-preview~$0.04/image
Style-matched variantsgemini-3-pro-image-preview + reference image~$0.04/image

Verify current model IDs if errors occur — they change frequently.

Reference Files

WhenRead
Building effective promptsreferences/prompting-guide.md
API implementation detailsreferences/api-pattern.md

Source

git clone https://github.com/jezweb/claude-skills/blob/main/plugins/design-assets/skills/gemini-image-gen/SKILL.mdView on GitHub

Overview

Generate contextual images for web projects using the Gemini API. It produces hero backgrounds, OG cards, placeholder photos, textures, and style-matched variants, with drafts on free-tier models and finals on paid plans. No dependencies beyond Python 3 are required.

How This Skill Works

Set GEMINI_API_KEY, then design prompts with concrete photography parameters and brand color anchors. A Python script posts to the Gemini API, parses the base64-encoded PNGs from the response, and saves one or more variants as PNG files (e.g., name-1.png, name-2.png). Supports multiple variants and style-matching by including a reference image when needed.

When to Use It

  • Need a hero background for a landing page with brand colors and mood
  • Need an OG image for social sharing that matches the brand
  • Need a placeholder stock-style photo for product mockups
  • Need style-matched variants to align visuals with a branding refresh
  • Need quick, draft assets before final client-ready images

Quick Start

  1. Step 1: Export GEMINI_API_KEY in your environment
  2. Step 2: Build a prompt using a preset (hero-background, og-image, etc.) with concrete photography parameters and palette anchors
  3. Step 3: Run the Python script (no external dependencies) to call the Gemini API, decode base64 PNGs, and save as name-1.png, name-2.png

Best Practices

  • Define target dimensions and count of variants before prompting
  • Use concrete photography parameters and color anchors from the palette
  • End prompts with a no-text, no-watermark, no-logos, no-hands rule
  • Prefer local image naming like name-1.png, name-2.png for variants
  • Avoid shell-based prompt passing; use Python's json.dumps or a file

Example Use Cases

  • Hero background for a SaaS product homepage in warm tones
  • OG image for a blog post featuring brand colors and subtle gradient
  • Placeholder stock photo for an e-commerce product page
  • Style-matched variant set for a brand refresh across pages
  • Texture pattern for a website background that harmonizes with palette

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers