gemini-image-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gemini Image Generator

Gemini 图片生成工具

Use this skill to turn a user prompt (and optional images) into Gemini image generation calls via the bundled Python scripts.
使用本Skill,通过内置Python脚本将用户提示词(及可选图片)转换为Gemini图片生成调用请求。

Workflow

工作流程

  1. Collect the user prompt and any images (local paths or URLs).
  2. Infer the operation mode and translate parameters into CLI flags.
  3. Run the appropriate script to generate or edit images.
  4. Return the output file paths.
  1. 收集用户提示词及所有图片(本地路径或URL)。
  2. 推断操作模式,将参数转换为CLI标志。
  3. 运行对应脚本以生成或编辑图片。
  4. 返回输出文件路径。

Defaults and Rules

默认设置与规则

  • Default model:
    gemini-2.5-flash-image
    (CLI value
    flash
    ).
  • Default aspect ratio:
    9:16
    .
  • Default count:
    1
    (max
    3
    ).
  • Default image size:
    1K
    , but only apply it for the Pro model.
  • If the user specifies a size (
    1K|2K|4K
    ), switch to Pro (
    gemini-3-pro-image-preview
    ).
  • If the user explicitly asks for Pro or higher quality, use Pro.
  • If the user supplies multiple reference images (2+), switch to Pro.
  • Logo overlay always uses Pro (even if the user asks for Flash).
  • Only set
    --size
    when using Pro.
  • 默认模型:
    gemini-2.5-flash-image
    (CLI参数值为
    flash
    )。
  • 默认宽高比:
    9:16
  • 默认生成数量:
    1
    (最大为
    3
    )。
  • 默认图片尺寸:
    1K
    ,但仅对Pro模型生效。
  • 若用户指定尺寸(
    1K|2K|4K
    ),自动切换为Pro模型(
    gemini-3-pro-image-preview
    )。
  • 若用户明确要求Pro或更高质量,使用Pro模型。
  • 若用户提供多张参考图(2张及以上),切换为Pro模型。
  • Logo叠加功能始终使用Pro模型(即使用户要求Flash版本)。
  • 仅在使用Pro模型时设置
    --size
    参数。

Allowed Values

允许的参数值

  • Aspect ratios:
    1:1
    ,
    2:3
    ,
    3:2
    ,
    3:4
    ,
    4:3
    ,
    4:5
    ,
    5:4
    ,
    9:16
    ,
    16:9
    ,
    21:9
    .
  • Image sizes (Pro only):
    1K
    ,
    2K
    ,
    4K
    .
  • Reference images (Pro): up to 14 total. Gemini guidance: up to 6 object images + up to 5 human images.
  • 宽高比:
    1:1
    ,
    2:3
    ,
    3:2
    ,
    3:4
    ,
    4:3
    ,
    4:5
    ,
    5:4
    ,
    9:16
    ,
    16:9
    ,
    21:9
  • 图片尺寸(仅Pro模型支持):
    1K
    ,
    2K
    ,
    4K
  • 参考图(Pro模型):最多14张。Gemini官方建议:最多6张物体图 + 最多5张人物图。

Script

脚本

Scripts

脚本列表

Text-to-image

文生图

Run:
bash
python scripts/generate_image.py \
  --prompt "<user prompt>" \
  --aspect 9:16 \
  --count 1 \
  --model flash \
  --out-dir outputs
Only add flags when the user asks for them. The script reads
GEMINI_API_KEY
from the environment.
运行命令:
bash
python scripts/generate_image.py \
  --prompt "<user prompt>" \
  --aspect 9:16 \
  --count 1 \
  --model flash \
  --out-dir outputs
仅当用户明确要求时才添加对应标志。脚本会从环境变量中读取
GEMINI_API_KEY

Image editing / image-to-image

图片编辑 / 图生图

Use when the user supplies a base image to edit or transform.
Run:
bash
python scripts/edit_image.py \
  --input /path/to/base.png \
  --prompt "<edit instructions>" \
  --reference /path/to/ref1.png \
  --reference https://example.com/ref2.png \
  --aspect 9:16 \
  --count 1 \
  --model flash \
  --out-dir outputs
当用户提供基础图片用于编辑或转换时使用。
运行命令:
bash
python scripts/edit_image.py \
  --input /path/to/base.png \
  --prompt "<edit instructions>" \
  --reference /path/to/ref1.png \
  --reference https://example.com/ref2.png \
  --aspect 9:16 \
  --count 1 \
  --model flash \
  --out-dir outputs

Logo overlay

Logo叠加

Use when the user wants to place a logo onto a base image.
Run:
bash
python scripts/logo_overlay.py \
  --base /path/to/base.png \
  --logo /path/to/logo.png \
  --aspect 9:16 \
  --count 1 \
  --model pro \
  --out-dir outputs
当用户需要将Logo放置到基础图片上时使用。
运行命令:
bash
python scripts/logo_overlay.py \
  --base /path/to/base.png \
  --logo /path/to/logo.png \
  --aspect 9:16 \
  --count 1 \
  --model pro \
  --out-dir outputs

Examples

示例

User: "Generate a portrait of a dancer in a foggy forest." Claude:
  • Use defaults (flash, 9:16, count 1).
  • Run:
    python scripts/generate_image.py --prompt "Generate a portrait of a dancer in a foggy forest."
User: "Make a 2K 16:9 cinematic still of a neon city, give me 3 options." Claude:
  • Use Pro with size 2K, aspect 16:9, count 3.
  • Run:
    python scripts/generate_image.py --prompt "Make a 2K 16:9 cinematic still of a neon city" --aspect 16:9 --size 2K --count 3 --model pro
User: "Edit this image to remove the background and make it studio white." (with one image) Claude:
  • Use edit script with Flash.
  • Run:
    python scripts/edit_image.py --input /path/to/image.png --prompt "Remove the background and make it studio white."
User: "Put this logo on the shirt in the photo." (with base + logo images) Claude:
  • Use logo overlay script (Pro).
  • Run:
    python scripts/logo_overlay.py --base /path/to/photo.png --logo /path/to/logo.png
用户:“生成一张舞者在迷雾森林中的肖像照。” Claude:
  • 使用默认设置(flash模型、9:16宽高比、生成1张)。
  • 运行命令:
    python scripts/generate_image.py --prompt "Generate a portrait of a dancer in a foggy forest."
用户:“生成3张2K分辨率、16:9比例的霓虹城市场景电影静帧。” Claude:
  • 使用Pro模型,设置尺寸2K、宽高比16:9、生成数量3。
  • 运行命令:
    python scripts/generate_image.py --prompt "Make a 2K 16:9 cinematic still of a neon city" --aspect 16:9 --size 2K --count 3 --model pro
用户:“编辑这张图片,移除背景并改为纯白工作室背景。”(附带一张图片) Claude:
  • 使用编辑脚本及Flash模型。
  • 运行命令:
    python scripts/edit_image.py --input /path/to/image.png --prompt "Remove the background and make it studio white."
用户:“把这个Logo放到照片里的衬衫上。”(附带基础图片+Logo图片) Claude:
  • 使用Logo叠加脚本(Pro模型)。
  • 运行命令:
    python scripts/logo_overlay.py --base /path/to/photo.png --logo /path/to/logo.png

Notes

注意事项

  • If the script fails with a missing module, install
    google-genai
    and retry.
  • Dependencies live in
    scripts/requirements.txt
    (install with
    pip install -r scripts/requirements.txt
    ).
  • Output files are written into the
    outputs/
    directory using timestamped names.
  • For prompt best practices and templates, read
    references/prompt-guide.md
    .
  • For logo-specific guidance, read
    references/logo-overlay.md
    .
  • For edit/image-to-image guidance, read
    references/image-editing.md
    .
  • For watermarking guidance, read
    references/watermarking.md
    .
  • 若脚本因缺失模块运行失败,请安装
    google-genai
    后重试。
  • 依赖包列表位于
    scripts/requirements.txt
    (可通过
    pip install -r scripts/requirements.txt
    安装)。
  • 输出文件将以时间戳命名,保存至
    outputs/
    目录。
  • 关于提示词最佳实践及模板,请查阅
    references/prompt-guide.md
  • 关于Logo叠加的具体指南,请查阅
    references/logo-overlay.md
  • 关于图片编辑/图生图的指南,请查阅
    references/image-editing.md
  • 关于水印添加的指南,请查阅
    references/watermarking.md