SuperAPI AI 工具集

Nano Banana Image Generation

设计与创作

查看项目

更新于 10-16 02:05

技能介绍

用途

Nano Banana Image Generation 用于调用 Google 的 Gemini 图像模型来生成和编辑图像。当用户要求用 AI 创建、生成、制作或编辑图片时,可使用该技能。

前置条件

  • 必须设置 GEMINI_API_KEY 环境变量。
  • 该 CLI 通过 npx @the-focus-ai/nano-banana 安装/调用。

环境变量设置方式:

export GEMINI_API_KEY="your-api-key-here"

或在项目中创建 .env 文件:

GEMINI_API_KEY=your-api-key-here

快速参考

生成新图像:

npx @the-focus-ai/nano-banana "a serene mountain landscape at sunset"

编辑已有图像:

npx @the-focus-ai/nano-banana "add a hot air balloon to the sky" --file photo.jpg

指定输出路径:

npx @the-focus-ai/nano-banana "a minimalist logo" --output logo.png

使用指定模型:

npx @the-focus-ai/nano-banana "detailed illustration" --model gemini-2.5-flash-image

工作流

第一步:理解需求

生成前先明确:主题(图像中应包含什么)、风格(照片写实、插画、卡通、抽象)、氛围(明亮、暗沉、忧郁、欢快)、构图(特写、广角、特定宽高比)、用途(主图、图标、社交媒体、印刷)。

第二步:编写有效的提示词

关键原则: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"

第三步:生成图像

npx @the-focus-ai/nano-banana "your detailed prompt here"

默认输出:output/generated-<timestamp>.png

第四步:迭代

如果结果不理想:优化提示词(增加细节或约束)、编辑图像(用 --file 修改已生成图像)、尝试不同模型(某些模型对特定风格处理更好)。

命令

文本生成图像:

npx @the-focus-ai/nano-banana "<prompt>"

图像编辑:

npx @the-focus-ai/nano-banana "<edit instruction>" --file <input-image>

编辑指令应描述具体改动,例如:

  • "Remove the background and replace with a gradient"
  • "Add sunglasses to the person"
  • "Change the sky to sunset colors"
  • "Make it look like a watercolor painting"

选项

  • --file <image>:用于编辑的输入图像
  • --output <path>:自定义输出路径
  • --model <name>:指定 Gemini 模型
  • --flash:使用 gemini-2.5-flash-image(更快、更简单的图像)
  • --prompt-file <path>:从文件读取提示词
  • --list-models:显示可用模型

最佳实践

获得更好结果:先描述构图再补充细节;使用艺术参考(如 "in the style of Studio Ghibli"、"like a National Geographic photo");指定光照("golden hour lighting"、"dramatic chiaroscuro"、"soft diffused light");在提示词中写明要避免的内容;模型默认生成方形图像,如需宽/高可在提示词中说明。

编辑时:具体说明改动("Add a blue butterfly to the top-left corner");保留有效部分("Keep the background unchanged, only modify the foreground");逐步迭代,一次做一个改动以便更好控制。

保持一致时:在提示词中建立风格指南;跨提示词使用相同风格描述词;编辑后续图像时参考第一张图。

示例提示词

头图/主图:

"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),更明确地表达需求。

图像与描述不符:更明确地说明构图,增加负面约束("no X, no Y"),尝试将复杂提示词拆分为更简单的部分。

限制

定价、费用与具体可用模型清单等资料暂未提供,请以 --list-models 实际输出及官方说明为准。