360 Secure SkillHub
360 安全技能中心

Generate Image

通过 generate-image CLI 调用 Gemini 图像模型(gemini-2.5-flash-image、gemini-3-pro-image-preview)进行文生图与参考图编辑,支持多种宽高比、最高 4K 分辨率和一次生成多个变体,输出 PNG 文件并在 stdout 返回 JSON 结果,另附提示词与编辑模板文档。

quochungto
quochungto
热度 20.28
最近更新 2026-04-06 21:31:46
分类:创作依赖:代码执行 / 读写文件 / 第三方 API应用场景:图像生成 / 品牌素材 / 社交媒体

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add generate-image
Metadata
name
generate-image
description
Generate images using the generate-image CLI. Use when creating images, product photos, starting frames, or editing images with Gemini models (gemini-2.5-flash-image, gemini-3-pro-image-preview).
user-invocable
true
slug
generate-image
tagline
AI product photos. Any product. Seconds.
category
image
icon
🖼
keywords
["product photos","AI image generation","gemini image API","product photography AI","image editing AI"]
stats
[{"value":"4","label":"Variants per run"},{"value":"<20s","label":"Generation time"},{"value":"Free","label":"No card needed"}]
faq
[{"q":"What models does it support?","a":"Gemini 2.5 Flash Image for fast iteration and Gemini 3 Pro Image Preview for high-quality output. Both support text-to-image and image editing with reference images."},{"q":"Can I use my own product photos as references?","a":"Yes — pass reference images as input for style transfer, composition guidance, or editing. The model preserves your product's appearance while generating new scenes and angles."},{"q":"What output formats and sizes are available?","a":"Any aspect ratio (1:1, 9:16, 16:9, 4:3, 3:4) and up to 2K resolution. Output is PNG format, ready for social media or e-commerce platforms."}]
install
{"skillsmp_url":"https://skillsmp.com/skill/generate-image","github_url":"https://github.com/genieus/genieus-skills/tree/main/skills/generate-image"}
display-name
Generate AI Product Photos
display-description
Create studio-quality product images with Gemini AI models. Generate multiple variants from a single prompt, use reference images for style transfer, and output in any aspect ratio — perfect for e-commerce listings, social media, and ad creatives.
sample-output
✓ Generated 4 product photo variants (9:16) Output files: images/product_shot_1.png — clean studio, white background images/product_shot_2.png — lifestyle, wooden table setting images/product_shot_3.png — creator holding product, natural light images/product_shot_4.png — flat lay with complementary items
related-slugs
["generate-video","ugc-video"]
try-it-command
/generate-image --prompt 'product photo of [your product]' --variants 4
features
[{"name":"Text-to-image","color":"accent","description":"Generate product photos from text descriptions alone"},{"name":"Reference editing","color":"cyan","description":"Use your own product photos as style and composition guides"},{"name":"Multi-variant","color":"purple","description":"Generate up to 4 unique variants from a single prompt"}]
case-study
{"title":"Coffee Mug · 4 variants","input":{"prompt":"Ceramic coffee mug on concrete surface, studio lighting","model":"gemini-3-pro-image-preview","variants":"4"},"output":"✓ Generated 4 product photo variants (1:1, 2K)\nOutput:\n images/mug_1.png — Clean studio, white background, soft shadow\n images/mug_2.png — Lifestyle, wooden desk with notebook\n images/mug_3.png — Overhead flat lay with coffee beans\n images/mug_4.png — Hand holding mug, morning light through window\n\nGeneration time: 14s\nModel: gemini-3-pro-image-preview\n"}

generate-image CLI

Generate images using Gemini's Nano Banana model series. The CLI handles API calls, reference image loading, multi-variant generation, and JSON output.

When to Use This Skill

  • User asks to generate, create, or edit an image
  • User needs product photos, starting frames, or visual assets
  • User mentions Gemini image generation, Nano Banana, or specific model IDs
  • User wants to generate multiple image variants from a single prompt

CLI Usage

generate-image \
  --provider google \
  --model <model-id> \
  --prompt "your prompt" \
  --output path/to/output.png \
  [--aspect-ratio 9:16] \
  [--references path/to/ref1.png --references path/to/ref2.png] \
  [--variants 4] \
  [--image-size 2K]

Flags

Flag Required Default Description
--provider Yes — Provider name: google
--model Yes — Model ID (see Model Comparison below)
--prompt Yes — Generation prompt
--output Yes — Output file path (e.g. images/photo.png)
--aspect-ratio No 9:16 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
--references No — Reference image paths. Repeat flag for each file.
--variants No 1 Number of variants to generate (outputs _1.png, _2.png, etc.)
--image-size No — Resolution: 1K, 2K, 4K (Pro model only, uppercase K)

Model Comparison

Model ID Best For Resolution Speed Max References
Nano Banana gemini-2.5-flash-image High-volume, low-latency, rapid iteration 1024px Fast 3
Nano Banana Pro gemini-3-pro-image-preview Professional assets, complex instructions, text-in-image Up to 4K Slower 14 (5 high-fidelity)

See models/gemini-flash.md and models/gemini-pro.md for details.

JSON Output

All output goes to stdout as JSON. Progress messages go to stderr.

Success

{
  "status": "success",
  "provider": "google",
  "model": "gemini-2.5-flash-image",
  "output_files": ["images/photo_1.png", "images/photo_2.png"],
  "elapsed_seconds": 12.5,
  "metadata": {}
}

Error

{
  "status": "error",
  "provider": "google",
  "model": "gemini-2.5-flash-image",
  "error_code": "generation_failed",
  "error_message": "Content policy violation",
  "elapsed_seconds": 2.1
}

Exit Codes

Code Meaning
0 Success
1 Generation failed (content_policy, timeout, quota_exceeded, etc.)
2 Invalid provider or model
3 Proxy unreachable

Error Handling

error_code Meaning Recovery
generation_failed General generation failure Check prompt, retry
content_policy Prompt violates content policy Adjust prompt, remove banned content
timeout Generation took too long Retry
quota_exceeded Rate limit hit Wait 30s, retry
invalid_image Bad reference image Check image format/path
proxy_unreachable GenAI proxy is down Cannot proceed, skip generation

Examples

Text-to-image (Flash, fast)

generate-image \
  --provider google \
  --model gemini-2.5-flash-image \
  --prompt "A photorealistic close-up of a ceramic coffee mug on a concrete surface, soft studio lighting" \
  --output images/mug.png \
  --aspect-ratio 1:1

With product references (Pro, high quality)

generate-image \
  --provider google \
  --model gemini-3-pro-image-preview \
  --prompt "A creator holds the product naturally, casual selfie style, warm indoor lighting" \
  --output images/creator_shot.png \
  --aspect-ratio 9:16 \
  --references product_images/product_1.png \
  --references product_images/product_2.png \
  --image-size 2K

Multi-variant generation

generate-image \
  --provider google \
  --model gemini-3-pro-image-preview \
  --prompt "UGC-style starting frame with product" \
  --output images/starting_frame.png \
  --aspect-ratio 9:16 \
  --references product_images/product_1.png \
  --variants 4

Outputs: starting_frame_1.png, starting_frame_2.png, starting_frame_3.png, starting_frame_4.png

Prompting

Good prompts are descriptive narratives, not keyword lists. See:

  • Best practices — Prompting strategies, camera control, model-specific tips
  • Generation templates — 7 templates: photorealistic, stylized, text-in-image, product mockups, minimalist, sequential art, search-grounded
  • Editing templates — 6 techniques: add/remove elements, inpainting, style transfer, multi-image composition, detail preservation, sketch-to-photo
  • Character consistency — Multi-angle 360-degree character generation

Limitations

  • All generated images include a SynthID watermark
  • Best performance in: EN, ar-EG, de-DE, es-MX, fr-FR, hi-IN, id-ID, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, ua-UA, vi-VN, zh-CN
  • For text-in-image accuracy, generate text first then ask for image with text
  • Flash: best with up to 3 input images; Pro: 5 high-fidelity + up to 14 total

What's next? Use these images in a full UGC pipeline

You've generated product photos. On the Genieus platform, these become starting frames for UGC videos — the agent writes the script, picks the best frame, and renders a 15-second video.

On genieus.io:

  • Product photos → UGC video starting frames
  • AI script generation matched to your visuals
  • Full campaign from images to published video ads

Create video from your images →