gemini-image-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gemini Image Generator

Gemini图片生成工具

Generate images using Google Gemini's image generation capabilities.
借助Google Gemini的图片生成功能来创建图片。

Prerequisites

前置要求

  • Python 3.8+
  • Google AI Studio API key
  • Virtual environment with dependencies
  • Python 3.8+
  • Google AI Studio API密钥
  • 包含依赖项的虚拟环境

Setup

设置步骤

bash
undefined
bash
undefined

Navigate to scripts directory

Navigate to scripts directory

cd scripts
cd scripts

Create virtual environment

Create virtual environment

python3 -m venv venv
python3 -m venv venv

Install dependencies

Install dependencies

./venv/bin/pip install -r requirements.txt # Unix
./venv/bin/pip install -r requirements.txt # Unix

or

or

.\venv\Scripts\pip install -r requirements.txt # Windows
.\venv\Scripts\pip install -r requirements.txt # Windows

Set API key

Set API key

export GEMINI_API_KEY="your-api-key" # Unix
export GEMINI_API_KEY="your-api-key" # Unix

or

or

$env:GEMINI_API_KEY = "your-api-key" # PowerShell

Get your API key from [Google AI Studio](https://aistudio.google.com/apikey).
$env:GEMINI_API_KEY = "your-api-key" # PowerShell

从[Google AI Studio](https://aistudio.google.com/apikey)获取你的API密钥。

Usage

使用方法

Basic Text-to-Image

基础文本转图片

bash
python generate.py --prompt "A serene mountain landscape at sunset" --output landscape.png
bash
python generate.py --prompt "A serene mountain landscape at sunset" --output landscape.png

With Reference Image (Style Transfer)

结合参考图片(风格迁移)

bash
python generate.py --prompt "Same scene but in winter" --reference landscape.png --output winter.png
bash
python generate.py --prompt "Same scene but in winter" --reference landscape.png --output winter.png

Prompt Engineering Tips

提示词设计技巧

For best results, structure prompts as:
[Subject] + [Style] + [Composition] + [Technical] + [Mood]
Example for game assets:
"A bio-mimetic robot with Art Nouveau brass gears and botanical vine patterns, 
centered composition on transparent background, flat vector style suitable for 
game sprite, warm golden hour lighting, whimsical and charming mood"
Style keywords that work well:
  • Art styles: Art Nouveau, steampunk, Studio Ghibli, pixel art, vector illustration
  • Technical: transparent background, game sprite, icon, UI element, seamless texture
  • Mood: whimsical, dramatic, cozy, ethereal, vibrant
为获得最佳效果,请按照以下结构设计提示词:
[主体] + [风格] + [构图] + [技术要求] + [氛围]
游戏资产示例:
"A bio-mimetic robot with Art Nouveau brass gears and botanical vine patterns, 
centered composition on transparent background, flat vector style suitable for 
game sprite, warm golden hour lighting, whimsical and charming mood"
效果较好的风格关键词:
  • 艺术风格:新艺术运动(Art Nouveau)、蒸汽朋克、吉卜力工作室风格、像素画、矢量插画
  • 技术要求:透明背景、游戏精灵、图标、UI元素、无缝纹理
  • 氛围:奇幻、戏剧性、温馨、空灵、充满活力

Parameters

参数说明

ParameterRequiredDescription
--prompt
YesText description of desired image
--output
YesOutput file path (.png)
--reference
NoReference image for style guidance
参数是否必填描述
--prompt
所需图片的文本描述
--output
输出文件路径(.png格式)
--reference
用于风格引导的参考图片

Troubleshooting

故障排除

ErrorSolution
API key not validCheck GEMINI_API_KEY is set correctly
403 ForbiddenAPI key may have IP restrictions
Model not foundModel names change; check Google AI docs
No image generatedTry simpler prompt, check API quota
错误解决方案
API密钥无效检查GEMINI_API_KEY是否配置正确
403 禁止访问API密钥可能存在IP限制
模型未找到模型名称可能已变更,请查看Google AI文档
未生成图片尝试使用更简单的提示词,检查API配额

Integration with Game Assets Team

与游戏资产团队的集成

This skill is the primary image generation tool for the
game-assets-team
skill. Use it for:
  • Concept art exploration
  • UI element generation
  • Character/Simulin designs
  • Background and environment art
  • Promotional materials
Always follow the art direction guidelines in game-assets-team for consistent visual style.
本工具是
game-assets-team
工具的主要图片生成工具。可用于:
  • 概念艺术探索
  • UI元素生成
  • 角色/模拟生物设计
  • 背景与环境艺术
  • 宣传物料
请始终遵循游戏资产团队的艺术指导规范,以保持视觉风格的一致性。