关于 nano-banana-imagegen
nano-banana-imagegen 是一项通过 `nano-banana` 命令行使用 Google 的 Gemini 图像模型生成和编辑图像的技能,支持文本提示词创作、编辑输入图像、选择模型及指定输出路径。
主要功能
- 01根据文本提示词生成图像
- 02通过 `--file` 编辑输入图像
- 03选择 Gemini 模型
- 04指定自定义输出路径
- 05从文件读取提示词
- 06列出可用模型
适用场景
- 01制作博客页眉图像
- 02对现有照片进行定向修改
- 03生成产品图或插画
- 04设计图标或 Logo 概念
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ the-focus-ai/ nano-banana-cli --skill nano-banana-imagegen安装后在 Claude Code 中输入/nano-banana-imagegen确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
prompting-guide.mdexamples/headers-and-heroes.mdicons-and-logos.mdillustrations.mdphotography-and-editing.md详细介绍
Nano Banana 图像生成
通过 nano-banana CLI 使用 Google 的 Gemini 图像模型生成和编辑图像。
前置条件
- 必须设置
GEMINI_API_KEY环境变量 - 通过
npx @the-focus-ai/nano-banana安装 CLI
快速参考
# Generate a new image
npx @the-focus-ai/nano-banana "a serene mountain landscape at sunset"
# Edit an existing image
npx @the-focus-ai/nano-banana "add a hot air balloon to the sky" --file photo.jpg
# Specify output path
npx @the-focus-ai/nano-banana "a minimalist logo" --output logo.png
# Use a specific model
npx @the-focus-ai/nano-banana "detailed illustration" --model gemini-2.5-flash-image
工作流
步骤 1:了解需求
生成前,请先明确:
- 主体:图像中应包含什么?
- 风格:写实、插画、卡通还是抽象?
- 氛围:明亮、昏暗、忧郁还是欢快?
- 构图:特写、广角,还是指定宽高比?
- 用途:主视觉图、图标、社交媒体还是印刷品?
步骤 2:编写有效的提示词
请参阅 prompting-guide.md,了解全面的指导。
关键原则:
- 具体且描述详尽
- 加入风格参考
- 说明你不想要什么
- 描述构图和取景
示例 - 较弱的提示词:
"a cat"
示例 - 较强的提示词:
"A fluffy orange tabby cat curled up on a velvet armchair, soft afternoon sunlight streaming through a window, warm cozy interior, photorealistic style, shallow depth of field"
步骤 3:生成图像
npx @the-focus-ai/nano-banana "your detailed prompt here"
默认输出:output/generated-<timestamp>.png
步骤 4:迭代
如果结果不理想:
- 优化提示词 - 添加更多细节或约束
- 编辑图像 - 使用
--file修改生成的图像 - 尝试其他模型 - 某些模型更擅长处理特定风格
命令
文本生成图像
npx @the-focus-ai/nano-banana "<prompt>"
图像编辑
npx @the-focus-ai/nano-banana "<edit instruction>" --file <input-image>
编辑指令应描述要做的更改:
- “移除背景并替换为渐变”
- “给人物戴上太阳镜”
- “将天空改为日落色调”
- “让它看起来像一幅水彩画”
选项
| 选项 | 描述 |
|---|---|
--file <image> | 用于编辑的输入图像 |
--output <path> | 自定义输出路径 |
--model <name> | 指定 Gemini 模型 |
--flash | 使用 gemini-2.5-flash-image(速度更快,适合生成较简单的图像) |
--prompt-file <path> | 从文件读取提示词 |
--list-models | 显示可用模型 |
最佳实践
获得更好的结果
- 从构图开始:先描述布局,再补充细节
- 使用艺术风格参考:“采用 Studio Ghibli 风格”“如同 National Geographic 照片”
- 指定光线:“黄金时刻光线”“戏剧性的明暗对照”“柔和的漫射光”
- 加入负向指引:在提示词中描述应避免的内容
- 考虑宽高比:模型默认生成正方形图像;如有需要,请描述横向或纵向构图
图像编辑
- 明确说明更改内容:“在左上角添加一只蓝色蝴蝶”
- 保留有效内容:“保持背景不变,只修改前景”
- 迭代优化:每次只做一项更改,以便更好地控制结果
保持一致性
创建多张相关图像时:
- 在提示词中制定风格指南
- 在各个提示词中使用相同的风格描述
- 编辑后续图像时参考第一张图像
提示词示例
完整的提示词示例请参阅 examples/ 目录。
标题/主视觉图
"Wide 16:9 header image for a technology blog. Clean minimalist design with
abstract geometric shapes in teal and orange. Bright white background,
editorial magazine aesthetic. No text, no dark colors, no gradients."
产品摄影风格
"Professional product photo of a ceramic coffee mug on a marble surface.
Soft natural lighting from the left, subtle shadow, clean white background.
Commercial photography style, 4K quality, sharp focus on the product."
插画
"Whimsical children's book illustration of a fox reading a book under a
large oak tree. Soft watercolor style, warm autumn colors, gentle and
inviting mood. Simple composition with the fox as the focal point."
图标和徽标
"Minimalist app icon for a meditation app. Simple lotus flower symbol in
a soft purple gradient. Clean geometric design, works at small sizes,
modern and calming aesthetic."
故障排除
“No image in response”
- 提示词可能触发了安全过滤器
- 尝试改用含义更明确的措辞
- 检查模型是否支持图像生成
结果质量较差
- 提供更具体的风格指引
- 使用能力更强的模型(
gemini-2.5-flash-image) - 更明确地描述你的需求
图像与描述不符
- 更明确地描述构图
- 添加负向约束(“不要 X,不要 Y”)
- 尝试将复杂提示词拆分为更简单的部分
环境设置
确保已设置 GEMINI_API_KEY:
export GEMINI_API_KEY="your-api-key-here"
或者在项目中创建 .env 文件:
GEMINI_API_KEY=your-api-key-here
评论
支持 Markdown