# Gemini Imagegen

Generate and edit images using Google Gemini's native image generation models (Nano...

- Repository: https://github.com/dp-archive/archive (1107 stars)
- Category: Media
- License: Apache-2.0
- Last updated: 2026-03-04
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add dp-archive/archive --skill gemini-imagegen -g -a claude-code -y`
Codex: `npx skills add dp-archive/archive --skill gemini-imagegen -g -a codex -y`
Cursor: `npx skills add dp-archive/archive --skill gemini-imagegen -g -a cursor -y`
Gemini CLI: `npx skills add dp-archive/archive --skill gemini-imagegen -g -a gemini-cli -y`

## Description

Generate and edit images using Google Gemini's native image generation models (Nano Banana / Nano Banana Pro). Supports text-to-image, image editing with reference images, multi-image composition, and character consistency. Use when the user asks to generate images via Gemini, create AI illustrations, edit photos with Gemini, or needs high-quality image generation with the Google API. Requires GEMINI_API_KEY. Triggers: "generate image with gemini", "nano banana", "gemini image", "create illustration", "AI generate picture", "text to image".

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Gemini Image Generation

Generate and edit images via Google Gemini's native multimodal image generation.

## Model Selection

| Model ID | Codename | Best for | Max resolution |
|----------|----------|----------|---------------|
| `gemini-2.5-flash-image` | Nano Banana | Fast drafts, high-volume, low-latency | 1K |
| `gemini-3-pro-image-preview` | Nano Banana Pro | Studio-quality, text rendering, complex prompts | 4K |

Default: `gemini-3-pro-image-preview` (Pro) unless speed/cost is a concern.

## Setup

```python
# Install (once)
# pip install google-genai

from google import genai
import os, base64

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
```

If `GEMINI_API_KEY` is missing, instruct the user to set it as an environment variable.
Never ask the user to paste the key in chat.

## Text-to-Image

```python
from google import genai
from google.genai import types
import os

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])

response = client.models.generate_content(
    model="gemini-3-pro-image-preview",
    contents="A photorealistic cat on a rainbow sofa",
    config=types.GenerateContentConfig(
        response_modalities=["TEXT", "IMAGE"],
    ),
)

# Extract and save
for part in response.candidates[0].content.parts:
    if part.inline_data is not None:
        with open("output.png", "wb") as f:
            f.write(part.inline_data.data)
        break
```

## Aspect Ratio

Set via `image_config`:

```python
config=types.GenerateContentConfig(
    response_modalities=["TEXT", "IMAGE"],
    image_config=types.ImageConfig(
        aspect_ratio="16:9",  # for slides / widescreen
    ),
)
```

Supported ratios: `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`

Common choices:
- Slides / presentations → `16:9`
- Social media / portraits → `9:16` or `4:5`
- Square thumbnails → `1:1`

## Image Editing (with reference image)

```python
from google.genai import types
from pathlib import Path
import base64

The rest: https://github.com/dp-archive/archive/blob/HEAD/seed_skills/gemini-imagegen/SKILL.md
