mcpField
N
Nano Banana Image Generation

Nano Banana Image Generation

github.com/the-focus-ai创意与媒体2049 次安装16 周前更新
代码仓库

关于 Nano Banana Image Generation

Nano Banana Image Generation 是通过 nano-banana CLI 调用 Google Gemini 图像模型生成和编辑图片的技能,面向图像创作者。它支持文本生成图片,也可基于已有图片进行修改。

主要功能

  1. 01根据文本提示生成图片
  2. 02编辑已有图片
  3. 03选择 Gemini 模型
  4. 04指定输出路径
  5. 05从文件读取提示词

适用场景

  1. 01生成博客头图或社交媒体图片
  2. 02基于照片添加或修改元素
  3. 03制作产品图、插画或图标

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/the-focus-ai/nano-banana-cli --skill nano-banana-image-generation

安装后在 Claude Code 中输入/nano-banana-image-generation确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

prompting-guide.md
examples/
illustrations.md
photography-and-editing.md
icons-and-logos.md
headers-and-heroes.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,了解全面的指导。

关键原则:

  1. 具体且描述详尽
  2. 加入风格参考
  3. 说明你不想要什么
  4. 描述构图和取景

示例 - 较弱的提示词:

"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:迭代

如果结果不理想:

  1. 优化提示词 - 添加更多细节或约束
  2. 编辑图像 - 使用 --file 修改生成的图像
  3. 尝试其他模型 - 某些模型更擅长处理特定风格

命令

文本生成图像
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显示可用模型

最佳实践

获得更好的结果
  1. 从构图开始:先描述布局,再补充细节
  2. 使用艺术风格参考:“采用 Studio Ghibli 风格”“如同 National Geographic 照片”
  3. 指定光线:“黄金时刻光线”“戏剧性的明暗对照”“柔和的漫射光”
  4. 加入负向指引:在提示词中描述应避免的内容
  5. 考虑宽高比:模型默认生成正方形图像;如有需要,请描述横向或纵向构图
图像编辑
  1. 明确说明更改内容:“在左上角添加一只蓝色蝴蝶”
  2. 保留有效内容:“保持背景不变,只修改前景”
  3. 迭代优化:每次只做一项更改,以便更好地控制结果
保持一致性

创建多张相关图像时:

  1. 在提示词中制定风格指南
  2. 在各个提示词中使用相同的风格描述
  3. 编辑后续图像时参考第一张图像

提示词示例

完整的提示词示例请参阅 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