nanobanana

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nanobanana

Nanobanana

This is a guide for generating and editing images using the nanobanana CLI tool.
Nanobanana is a command-line interface for the Nano Banana image generation API, which uses Google's generative AI models.
这是一份使用nanobanana CLI工具借助生成式AI生成和编辑图片的指南。
Nanobanana是对接Nano Banana图片生成API的命令行界面,该API使用谷歌的生成式AI模型。

Installation

安装

If the nanobanana CLI is not already installed, install it using:
bash
go install maragu.dev/nanobanana@latest
如果尚未安装nanobanana CLI,可通过以下命令安装:
bash
go install maragu.dev/nanobanana@latest

Prerequisites

前提条件

The
GOOGLE_API_KEY
environment variable must be set, or a
.env
file with the key must be present in the working directory.
必须设置
GOOGLE_API_KEY
环境变量,或者在工作目录中存在包含该密钥的
.env
文件。

Generating images

生成图片

To generate a single image:
bash
nanobanana generate output.png "a beautiful sunset over mountains"
The output can be either a
.png
or
.jpg
file.
生成单张图片:
bash
nanobanana generate output.png "a beautiful sunset over mountains"
输出文件可以是
.png
.jpg
格式。

Using the pro model

使用专业版模型

To use the higher-quality pro model for generation:
bash
nanobanana generate -pro output.png "a beautiful sunset over mountains"
The
-pro
flag enables Google's premium generative AI model, which typically produces higher quality results but may take slightly longer to generate.
若要使用更高质量的专业版模型生成图片:
bash
nanobanana generate -pro output.png "a beautiful sunset over mountains"
-pro
标志会启用谷歌的高级生成式AI模型,该模型通常能生成更高质量的结果,但生成时间可能稍长。

Editing existing images

编辑现有图片

To edit or modify an existing image using a text prompt:
bash
nanobanana generate -i input.png output.png "make the sky purple and add stars"
This is useful for making specific changes to existing images based on natural language instructions.
使用文本提示词编辑或修改现有图片:
bash
nanobanana generate -i input.png output.png "make the sky purple and add stars"
这一功能可根据自然语言指令对现有图片进行特定修改,非常实用。

Tips for effective prompts

有效提示词技巧

  • Be specific and descriptive about what you want in the image
  • Include details about style, colors, mood, composition, and subject matter
  • For edits, clearly describe what should change while the rest remains the same
  • You can reference art styles, artists, or specific visual aesthetics
  • 对想要的图片内容要具体且描述详尽
  • 包含风格、颜色、氛围、构图和主题等细节
  • 进行编辑时,清晰描述需要更改的部分,同时说明其余部分保持不变
  • 可以参考艺术风格、艺术家或特定视觉美学

Examples

示例

Generate a logo:
bash
nanobanana generate logo.png "minimalist tech company logo with geometric shapes in blue and white"
Create concept art:
bash
nanobanana generate concept.png "futuristic city skyline at night with neon lights and flying vehicles, cyberpunk style"
Edit an existing photo:
bash
nanobanana generate -i photo.png enhanced.png "enhance the colors and make it look like golden hour"
生成logo:
bash
nanobanana generate logo.png "minimalist tech company logo with geometric shapes in blue and white"
创建概念艺术图:
bash
nanobanana generate concept.png "futuristic city skyline at night with neon lights and flying vehicles, cyberpunk style"
编辑现有照片:
bash
nanobanana generate -i photo.png enhanced.png "enhance the colors and make it look like golden hour"