Back to skills
SkillHub ClubShip Full StackFull Stack
gemini-image-generator
Generate images using Google Gemini with customizable options
Packaged view
This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.
Stars
29
Hot score
89
Updated
March 20, 2026
Overall rating
C3.2
Composite score
3.2
Best-practice grade
B80.4
Install command
npx @skill-hub/cli install mkdev-me-gemini-image-generator
Repository
mkdev-me/claude-skills
Skill path: gemini-image-generator
Generate images using Google Gemini with customizable options
Open repositoryBest for
Primary workflow: Ship Full Stack.
Technical facets: Full Stack.
Target audience: everyone.
License: Unknown.
Original source
Catalog source: SkillHub Club.
Repository owner: mkdev-me.
This is still a mirrored public skill entry. Review the repository before installing into production workflows.
What it helps with
- Install gemini-image-generator into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
- Review https://github.com/mkdev-me/claude-skills before adding gemini-image-generator to shared team environments
- Use gemini-image-generator for development workflows
Works across
Claude CodeCodex CLIGemini CLIOpenCode
Favorites: 0.
Sub-skills: 0.
Aggregator: No.
Original source / Raw SKILL.md
---
name: gemini-image-generator
description: Generate images using Google Gemini with customizable options
---
# gemini-image-generator
## Instructions
Use this skill to generate images using Google Gemini's image generation model. The skill supports:
- Text-to-image generation from prompts
- Image-to-image generation with a reference image
- Multiple output sizes (1K, 2K, 4K)
- Custom output paths
The API key must be set via the `GEMINI_API_KEY` environment variable.
## Parameters
- `--prompt` (required): The text prompt describing the image to generate
- `--output` (required): Output file path for the generated image
- `--reference`: Optional reference image for style/content guidance
- `--size`: Image size - "1K", "2K", or "4K" (default: 4K)
## Examples
### Basic text-to-image generation
```bash
./scripts/generate.py --prompt "A serene mountain landscape at sunset" --output images/landscape.png
```
### With reference image for style guidance
```bash
./scripts/generate.py --prompt "Same character but wearing a party hat" --reference images/character.png --output images/party.png
```
### Different output size
```bash
./scripts/generate.py --prompt "Abstract art" --output art.png --size 2K
```
## Setup
Before first use, set up the virtual environment:
```bash
cd scripts && python3 -m venv venv && ./venv/bin/pip install -r requirements.txt
```
Set your API key:
```bash
export GEMINI_API_KEY="your-api-key-here"
```
---
## Referenced Files
> The following files are referenced in this skill and included for context.
### scripts/generate.py
```python
#!/bin/sh
''''exec "`dirname $0`/venv/bin/python3" "$0" "$@" #'''
import argparse
import base64
import io
import os
import sys
from google import genai
from google.genai import types
from PIL import Image
def main():
parser = argparse.ArgumentParser(
description="Generate images using Google Gemini.",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
%(prog)s --prompt "A cat in space" --output cat.png
%(prog)s --prompt "Same style but blue" --reference input.png --output blue.png
%(prog)s --prompt "Abstract art" --output art.png --size 2K
"""
)
parser.add_argument(
"--prompt",
required=True,
help="Text prompt describing the image to generate"
)
parser.add_argument(
"--output",
required=True,
help="Output file path for the generated image"
)
parser.add_argument(
"--reference",
help="Optional reference image path for style/content guidance"
)
parser.add_argument(
"--size",
default="4K",
choices=["1K", "2K", "4K"],
help="Output image size (default: 4K)"
)
args = parser.parse_args()
# Get API key from environment
api_key = os.environ.get("GEMINI_API_KEY")
if not api_key:
print("Error: GEMINI_API_KEY environment variable not set.", file=sys.stderr)
print("Set it with: export GEMINI_API_KEY='your-api-key'", file=sys.stderr)
sys.exit(1)
client = genai.Client(api_key=api_key)
# Build content list
contents = [args.prompt]
# Add reference image if provided
if args.reference:
try:
reference_image = Image.open(args.reference)
contents.append(reference_image)
print(f"Using reference image: {args.reference}")
except FileNotFoundError:
print(f"Error: Reference image '{args.reference}' not found.", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"Error loading reference image: {e}", file=sys.stderr)
sys.exit(1)
# Create output directory if it doesn't exist
output_dir = os.path.dirname(args.output)
if output_dir and not os.path.exists(output_dir):
os.makedirs(output_dir)
print(f"Created output directory: {output_dir}")
print(f"Generating image with size: {args.size}...")
try:
response = client.models.generate_content(
model="gemini-2.0-flash-preview-image-generation",
contents=contents,
config=types.GenerateContentConfig(
response_modalities=["Text", "Image"],
)
)
except Exception as e:
print(f"Error generating image: {e}", file=sys.stderr)
sys.exit(1)
# Process response
image_saved = False
for part in response.candidates[0].content.parts:
if part.text is not None:
print(f"Model response: {part.text}")
elif part.inline_data is not None:
# Decode image data and save
image_data = base64.b64decode(part.inline_data.data)
generated_image = Image.open(io.BytesIO(image_data))
generated_image.save(args.output)
print(f"Image saved to: {args.output}")
image_saved = True
if not image_saved:
print("Warning: No image was generated in the response.", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()
```