Gemini Image Gen
Generate and edit images via the Google Gemini API using pure Python stdlib. Supports Gemini native generation + editing, Imagen 3 generation, batch runs, and an HTML gallery output.
Quick Start
CODEBLOCK0
Style Presets
| Style | Description |
|---|
| INLINECODE0 | Ultra-detailed photorealistic photography, 8K resolution, sharp focus |
| INLINECODE1 |
High-quality anime illustration, Studio Ghibli inspired, vibrant colors |
|
watercolor | Delicate watercolor painting on textured paper, soft edges, gentle color bleeding |
|
cyberpunk | Neon-lit cyberpunk scene, rain-soaked streets, holographic displays, Blade Runner aesthetic |
|
minimalist | Clean minimalist design, geometric shapes, limited color palette, white space |
|
oil-painting | Classical oil painting with visible brushstrokes, rich textures, Renaissance lighting |
|
pixel-art | Detailed pixel art, retro 16-bit style, crisp edges, nostalgic palette |
|
sketch | Pencil sketch on cream paper, hatching and cross-hatching, artistic imperfections |
|
3d-render | Professional 3D render, ambient occlusion, global illumination, photorealistic materials |
|
pop-art | Bold pop art style, Ben-Day dots, strong outlines, vibrant contrasting colors |
Full CLI Reference
| Flag | Default | Description |
|---|
| INLINECODE10 | (random) | Text prompt. Omit for random creative prompts |
| INLINECODE11 |
4 | Number of images to generate |
|
--engine | gemini | Engine:
gemini (native, supports edit) or
imagen (Imagen 3) |
|
--model | (auto) | Model override. Default:
gemini-2.5-flash-image or
imagen-3.0-generate-002 |
|
--edit | | Path to input image for editing (Gemini engine only) |
|
--aspect | 1:1 | Aspect ratio for Imagen:
1:1,
16:9,
9:16,
4:3,
3:4 |
|
--out-dir | (auto) | Output directory (default is a timestamped folder) |
|
--style | | Style preset to prepend to the prompt |
|
--styles | | List available style presets and exit |
Python Example
CODEBLOCK1
Troubleshooting
- - Missing API key: set
GEMINI_API_KEY in your environment and retry. - Rate limits / 429 errors: wait a bit and retry, reduce
--count, or switch engines. - Model errors: verify the model name, try the default model, or change engines.
Integration with Other Skills
- - AgentGram — Share your generated images on the AI agent social network! Create visual content and post it to your AgentGram feed.
- agent-selfie — Focused on AI agent avatars and visual identity. Uses the same Gemini API key for personality-driven self-portraits.
- opencode-omo — Run deterministic image-generation pipelines with Sisyphus workflows.
Changelog
- - v1.3.1: Added workflow integration guidance for opencode-omo.
- v1.1.0: Added style presets,
--style and --styles flags, expanded documentation. - v1.0.0: Initial release with Gemini native + Imagen 3 support, batch generation, and HTML gallery.
Repository
https://github.com/IISweetHeartII/gemini-image-gen
Gemini Image Gen
通过纯 Python 标准库,利用 Google Gemini API 生成和编辑图像。支持 Gemini 原生生成与编辑、Imagen 3 生成、批量运行以及 HTML 画廊输出。
快速开始
bash
export GEMINIAPIKEY=your-key-here
默认:Gemini 原生,4 个随机提示词
python3 scripts/gen.py
自定义提示词
python3 scripts/gen.py --prompt 一只赛博朋克猫在夜晚的东京骑着霓虹摩托车
Imagen 3 引擎
python3 scripts/gen.py --engine imagen --count 4 --aspect 16:9
编辑现有图像(仅限 Gemini 引擎)
python3 scripts/gen.py --edit path/to/image.png --prompt 将背景改为日落海滩
使用风格预设
python3 scripts/gen.py --style watercolor --prompt 平静海面上的浮空岛屿
列出可用风格
python3 scripts/gen.py --styles
风格预设
| 风格 | 描述 |
|---|
| photo | 超精细照片级写实摄影,8K 分辨率,锐利对焦 |
| anime |
高质量动漫插画,吉卜力工作室风格,色彩鲜艳 |
| watercolor | 纹理纸上的精致水彩画,柔和边缘,温和的色彩晕染 |
| cyberpunk | 霓虹灯照亮的赛博朋克场景,雨水浸湿的街道,全息显示屏,银翼杀手美学 |
| minimalist | 简洁的极简设计,几何形状,有限调色板,留白 |
| oil-painting | 古典油画,可见笔触,丰富纹理,文艺复兴式光影 |
| pixel-art | 精细像素艺术,复古 16 位风格,清晰边缘,怀旧色调 |
| sketch | 奶油色纸上的铅笔素描,排线与交叉排线,艺术性瑕疵 |
| 3d-render | 专业 3D 渲染,环境光遮蔽,全局光照,照片级材质 |
| pop-art | 大胆的波普艺术风格,本戴点,粗轮廓,鲜艳对比色 |
完整 CLI 参考
| 标志 | 默认值 | 描述 |
|---|
| --prompt | (随机) | 文本提示词。省略则使用随机创意提示词 |
| --count |
4 | 生成图像数量 |
| --engine | gemini | 引擎:gemini(原生,支持编辑)或 imagen(Imagen 3) |
| --model | (自动) | 模型覆盖。默认:gemini-2.5-flash-image 或 imagen-3.0-generate-002 |
| --edit | | 用于编辑的输入图像路径(仅限 Gemini 引擎) |
| --aspect | 1:1 | Imagen 的宽高比:1:1、16:9、9:16、4:3、3:4 |
| --out-dir | (自动) | 输出目录(默认为带时间戳的文件夹) |
| --style | | 要添加到提示词前的风格预设 |
| --styles | | 列出可用风格预设并退出 |
Python 示例
python
import subprocess
subprocess.run(
[
python3,
scripts/gen.py,
--prompt,
金色时刻的宁静山景,
--count,
4,
--style,
photo,
],
check=True,
)
故障排除
- - 缺少 API 密钥:在环境中设置 GEMINIAPIKEY 并重试。
- 速率限制 / 429 错误:稍等片刻后重试,减少 --count,或切换引擎。
- 模型错误:验证模型名称,尝试默认模型,或更换引擎。
与其他技能的集成
- - AgentGram — 在 AI 代理社交网络上分享您生成的图像!创建视觉内容并发布到您的 AgentGram 动态。
- agent-selfie — 专注于 AI 代理头像和视觉身份。使用相同的 Gemini API 密钥进行个性驱动的自画像。
- opencode-omo — 使用 Sisyphus 工作流运行确定性图像生成管道。
更新日志
- - v1.3.1:添加了 opencode-omo 的工作流集成指南。
- v1.1.0:添加了风格预设、--style 和 --styles 标志,扩展了文档。
- v1.0.0:初始版本,支持 Gemini 原生 + Imagen 3、批量生成和 HTML 画廊。
仓库
https://github.com/IISweetHeartII/gemini-image-gen