gemini-image-gen
Image generation with Google Gemini API. Models: gemini-2.5-flash-image (fast) or gemini-3-pro-image-preview (quality). For social media graphics, marketing, infographics.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Gemini Image Generation
Generate images directly from Claude Code CLI using Google's Gemini API.
Setup
API Key: https://aistudio.google.com/apikey
Environment Variable: GOOGLE_AI_API_KEY
Install: pip install google-genai pillow python-dotenv
Basic Usage
import os
from google import genai
client = genai.Client(api_key=os.environ.get("GOOGLE_AI_API_KEY"))
response = client.models.generate_content(
model="gemini-2.5-flash-image", # Fast
# model="gemini-3-pro-image-preview", # Quality
contents=["Your image prompt here"]
)
# Extract and save image from response
for part in response.candidates[0].content.parts:
if hasattr(part, 'inline_data') and part.inline_data:
with open("output.png", "wb") as f:
f.write(part.inline_data.data)
Models
| Model | Speed | Quality | Use Case |
|---|---|---|---|
gemini-2.5-flash-image |
Fast (~5s) | Good | Drafts, iterations |
gemini-3-pro-image-preview |
Slower (~15s) | Excellent | Final assets |
Use Cases
- Social media graphics
- Marketing materials
- Infographics
- Reddit/Discord banners
- Presentation slides
- Manufacturing dashboards (OEE gauges, SPC charts)
Advanced: Manufacturing Dashboard Example
prompt = """
Create a professional manufacturing OEE dashboard showing:
- Large OEE gauge at 85% (green zone)
- Three smaller KPI cards below:
- Availability: 92%
- Performance: 88%
- Quality: 99.2%
- Dark theme with blue/cyan accents
- Modern, executive-style design
"""
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=[prompt]
)
Image Compression for PPTX
When embedding in PowerPoint, compress images to avoid silent failures:
from PIL import Image
import io
def compress_image(data: bytes, max_size_kb: int = 200) -> bytes:
img = Image.open(io.BytesIO(data))
img = img.convert('RGB')
img.thumbnail((1280, 720))
buffer = io.BytesIO()
img.save(buffer, format='JPEG', quality=75, optimize=True)
return buffer.getvalue()
Real-World Usage
At fabrikIQ.com, Gemini Image Generation powers:
- AI-generated OEE dashboard visuals in PPTX exports
- Hero images for executive manufacturing reports
- Marketing materials for LinkedIn posts
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-28
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!