generate-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegenerate-image - AI Image Generation
generate-image - AI图像生成
Uses Google Gemini (gemini-3-pro-image-preview) to generate images from text prompts.
借助Google Gemini(gemini-3-pro-image-preview),通过文本提示词生成图像。
Synopsis
语法
bash
codev generate-image "<prompt>" [options]bash
codev generate-image "<prompt>" [options]Options
选项
bash
-o, --output <file> # Output file path (default: output.png)
-r, --resolution <res> # Resolution: 1K, 2K, 4K (default: 1K)
-a, --aspect <ratio> # Aspect ratio (default: 1:1)
--ref <image> # Reference image (repeatable, max 14)bash
-o, --output <file> # 输出文件路径(默认值:output.png)
-r, --resolution <res> # 分辨率:1K、2K、4K(默认值:1K)
-a, --aspect <ratio> # 宽高比(默认值:1:1)
--ref <image> # 参考图像(可重复使用,最多14张)Aspect Ratios
支持的宽高比
1:116:99:163:44:33:22:31:116:99:163:44:33:22:3Examples
示例
bash
undefinedbash
undefinedBasic generation
基础生成
codev generate-image "A sunset over mountains"
codev generate-image "A sunset over mountains"
High-res widescreen
高分辨率宽屏图像
codev generate-image "A futuristic city" -r 4K -a 16:9 -o city.png
codev generate-image "A futuristic city" -r 4K -a 16:9 -o city.png
With reference images (style transfer)
结合参考图像(风格迁移)
codev generate-image "Same style but with cats" --ref style.png --ref layout.png
codev generate-image "Same style but with cats" --ref style.png --ref layout.png
Prompt from file
从文件读取提示词
codev generate-image prompt.txt -o result.png
undefinedcodev generate-image prompt.txt -o result.png
undefinedPrerequisites
前置条件
Requires or environment variable.
Get a key at https://aistudio.google.com/apikey
GEMINI_API_KEYGOOGLE_API_KEYCommon Mistakes
常见错误
- Prompt must be quoted if it contains spaces
- Prompt can also be a file path (auto-detected by extension)
.txt - Reference images must exist on disk — max 14 images
- Output defaults to in current directory — use
output.pngto change-o
- 若提示词包含空格,必须用引号包裹
- 提示词也可以是文件路径(通过扩展名自动识别)
.txt - 参考图像必须存在于本地磁盘中——最多支持14张
- 输出文件默认保存在当前目录的——使用
output.png选项可修改路径-o