Nano Banana — image generation
Generate an image from a text prompt by running the script that lives next to this file:
bash <skill-dir>/generate.sh "<image prompt>" "<output-path.png|.jpg>"
Example (skill installed into Hermes):
bash ~/.hermes/skills/nano-banana/generate.sh "a cozy cabin in snowy mountains at dusk" ./post-cover.jpg
The script calls the Gemini API, extracts the base64 image from the response, decodes it,
and post-processes it according to the output extension and settings below.
Behavior
- On success it prints
OK: <path> (<N> bytes) and exits 0.
- If the API returns an error, the script prints the raw API response and exits 1.
Do not invent success — report the error to the user as is.
- The output path defaults to
/tmp/nano_out.png when omitted; the extension must be
.png, .jpg, or .jpeg.
Image size control
The Gemini API itself has no file-size or compression option for
gemini-2.5-flash-image — output is always a 1024px-class PNG (1-2 MB).
The API only accepts an aspect ratio; resolution presets (imageSize) exist
only on Gemini 3.x image models. Smaller files are produced by local
post-processing (postprocess.sh, used automatically by generate.sh):
- Output extension
.jpg / .jpeg converts to JPEG (NANO_BANANA_JPEG_QUALITY, default 85).
NANO_BANANA_MAX_DIM=800 downscales the longest side to 800 px.
- Typical result: 1.5 MB PNG becomes a 100-200 KB JPEG.
- Requires one of: ImageMagick,
sips (built into macOS), or Pillow.
Plain .png output without NANO_BANANA_MAX_DIM needs no tools and keeps
the original bytes.
Settings (.env)
Copy .env.example to .env next to the script and fill in the values.
Process environment variables take precedence over .env.
| Variable |
Required |
Default |
Meaning |
GEMINI_API_KEY |
yes |
— |
Google AI Studio API key |
GEMINI_IMAGE_MODEL |
no |
gemini-2.5-flash-image |
Image model to use |
GEMINI_ASPECT_RATIO |
no |
model default (1:1) |
API-side aspect ratio: 21:9, 16:9, 4:3, 3:2, 1:1, 9:16, 3:4, 2:3, 5:4, 4:5 |
GEMINI_IMAGE_SIZE |
no |
— |
API-side resolution preset (512px, 1K, 2K, 4K); Gemini 3.x image models only — 2.5 rejects it |
NANO_BANANA_MAX_DIM |
no |
— |
Downscale longest side to N px (local post-processing) |
NANO_BANANA_JPEG_QUALITY |
no |
85 |
JPEG quality 1-100 for .jpg output |
Verification
Criteria — the skill is ready only if all of these hold:
generate.sh and postprocess.sh pass a bash syntax check.
- Called without a prompt,
generate.sh prints usage to stderr and exits 2.
- With an invalid API key, it prints the API error, creates no output file, and exits 1.
- Post-processing (offline, no API): a locally crafted PNG converted with
NANO_BANANA_MAX_DIM=100 to .jpg produces a valid JPEG (magic bytes FF D8),
downscaled to <= 100 px; a plain .png pass-through keeps the original bytes.
- With a valid key, it generates a real image: exit 0, the output file exists,
starts with the PNG magic bytes, and is larger than 5 KB.
Run: ./check.sh (or tools/check-skill.sh nano-banana from the repo root).
Last verified: 2026-07-19 — tools/check-skill.sh nano-banana passed all checks, including real image generation.
1---2name: nano-banana3description: Generate images via the Gemini image API (nano banana). Use when you need to create a picture for a post, article, or any other image asset from a text prompt.4---56# Nano Banana — image generation78Generate an image from a text prompt by running the script that lives next to this file:910 bash <skill-dir>/generate.sh "<image prompt>" "<output-path.png|.jpg>"1112Example (skill installed into Hermes):1314 bash ~/.hermes/skills/nano-banana/generate.sh "a cozy cabin in snowy mountains at dusk" ./post-cover.jpg1516The script calls the Gemini API, extracts the base64 image from the response, decodes it,17and post-processes it according to the output extension and settings below.1819## Behavior2021- On success it prints `OK: <path> (<N> bytes)` and exits 0.22- If the API returns an error, the script prints the raw API response and exits 1.23 **Do not invent success** — report the error to the user as is.24- The output path defaults to `/tmp/nano_out.png` when omitted; the extension must be25 `.png`, `.jpg`, or `.jpeg`.2627## Image size control2829The Gemini API itself has no file-size or compression option for30`gemini-2.5-flash-image` — output is always a ~1024px-class PNG (~1-2 MB).31The API only accepts an aspect ratio; resolution presets (`imageSize`) exist32only on Gemini 3.x image models. Smaller files are produced by local33post-processing (`postprocess.sh`, used automatically by `generate.sh`):3435- Output extension `.jpg` / `.jpeg` converts to JPEG (`NANO_BANANA_JPEG_QUALITY`, default 85).36- `NANO_BANANA_MAX_DIM=800` downscales the longest side to 800 px.37- Typical result: 1.5 MB PNG becomes a 100-200 KB JPEG.38- Requires one of: ImageMagick, `sips` (built into macOS), or Pillow.39 Plain `.png` output without `NANO_BANANA_MAX_DIM` needs no tools and keeps40 the original bytes.4142## Settings (.env)4344Copy `.env.example` to `.env` next to the script and fill in the values.45Process environment variables take precedence over `.env`.4647| Variable | Required | Default | Meaning |48|----------|----------|---------|---------|49| `GEMINI_API_KEY` | yes | — | Google AI Studio API key |50| `GEMINI_IMAGE_MODEL` | no | `gemini-2.5-flash-image` | Image model to use |51| `GEMINI_ASPECT_RATIO` | no | model default (1:1) | API-side aspect ratio: `21:9`, `16:9`, `4:3`, `3:2`, `1:1`, `9:16`, `3:4`, `2:3`, `5:4`, `4:5` |52| `GEMINI_IMAGE_SIZE` | no | — | API-side resolution preset (`512px`, `1K`, `2K`, `4K`); Gemini 3.x image models only — 2.5 rejects it |53| `NANO_BANANA_MAX_DIM` | no | — | Downscale longest side to N px (local post-processing) |54| `NANO_BANANA_JPEG_QUALITY` | no | `85` | JPEG quality 1-100 for `.jpg` output |5556## Verification5758Criteria — the skill is ready only if all of these hold:59601. `generate.sh` and `postprocess.sh` pass a bash syntax check.612. Called without a prompt, `generate.sh` prints usage to stderr and exits 2.623. With an invalid API key, it prints the API error, creates no output file, and exits 1.634. Post-processing (offline, no API): a locally crafted PNG converted with64 `NANO_BANANA_MAX_DIM=100` to `.jpg` produces a valid JPEG (magic bytes `FF D8`),65 downscaled to <= 100 px; a plain `.png` pass-through keeps the original bytes.665. With a valid key, it generates a real image: exit 0, the output file exists,67 starts with the PNG magic bytes, and is larger than 5 KB.6869Run: `./check.sh` (or `tools/check-skill.sh nano-banana` from the repo root).7071Last verified: 2026-07-19 — `tools/check-skill.sh nano-banana` passed all checks, including real image generation.