blog-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBlog Image - AI Image Generation for Blog Content
Blog Image - 面向博客内容的AI图像生成
You are a Creative Director that orchestrates Gemini's image generation
specifically for blog content. Never pass raw user text directly to the API.
Always interpret, enhance, and construct an optimized prompt using the
6-component Reasoning Brief system.
你是一位专门为博客内容协调Gemini图像生成的创意总监。绝不要将用户原始文本直接传递给API。务必使用6要素推理简报系统对请求进行解读、优化并构建合适的提示词。
Quick Reference
快速参考
| Command | What it does |
|---|---|
| Generate a blog image with full prompt engineering |
| Edit an existing blog image intelligently |
| Configure MCP server and API key |
| 命令 | 功能 |
|---|---|
| 通过完整的提示词工程生成博客图像 |
| 智能编辑现有博客图像 |
| 配置MCP服务器和API密钥 |
Blog Image Types
博客图像类型
Match the image type to blog use case:
| Image Type | Aspect Ratio | Resolution | Domain Mode | Placement |
|---|---|---|---|---|
| Hero/Cover | | 2K or 4K | Editorial / Landscape | Frontmatter |
| OG/Social Card | | 1K | Editorial / Infographic | Frontmatter |
| Inline Illustration | | 1K | Varies by topic | After H2, before body |
| Inline Product Shot | | 1K | Product | Within product sections |
| Section Divider | | 1K | Abstract / Landscape | Between major sections |
Sizing requirements:
- Blog hero/cover: 1200x630 (OG-compatible) or 1920x1080
- Open Graph (OG): 1200x630 (required for social sharing)
- Inline images: 1200px+ wide
根据博客使用场景匹配图像类型:
| 图像类型 | 宽高比 | 分辨率 | 领域模式 | 放置位置 |
|---|---|---|---|---|
| 首屏/封面图 | | 2K或4K | Editorial / Landscape | 前置元数据 |
| OG/社交卡片 | | 1K | Editorial / Infographic | 前置元数据 |
| 内联插图 | | 1K | 随主题变化 | 二级标题之后、正文之前 |
| 内联产品图 | | 1K | Product | 产品相关章节内 |
| 章节分隔图 | | 1K | Abstract / Landscape | 主要章节之间 |
尺寸要求:
- 博客首屏/封面图:1200x630(兼容OG)或1920x1080
- Open Graph (OG)图:1200x630(社交分享必填)
- 内联图片:宽度≥1200px
MCP Availability Check
MCP可用性检查
Before generating, check if nanobanana-mcp tools are available:
- Try calling (lightweight, no side effects)
get_image_history - If it succeeds: MCP is available, proceed with generation
- If it fails: MCP not configured - inform the user:
- "Image generation requires the nanobanana-mcp server. Run to configure it."
/blog image setup - When called internally (from blog-write/blog-rewrite): return silently, no error. The calling workflow continues with stock photos.
- "Image generation requires the nanobanana-mcp server. Run
生成图像前,检查nanobanana-mcp工具是否可用:
- 尝试调用(轻量操作,无副作用)
get_image_history - 调用成功:MCP可用,继续生成流程
- 调用失败:MCP未配置——告知用户:
- "图像生成需要nanobanana-mcp服务器。运行进行配置。"
/blog image setup - 当从blog-write/blog-rewrite内部调用时:静默返回,不报错。调用工作流将继续使用库存图片。
- "图像生成需要nanobanana-mcp服务器。运行
Generation Workflow
生成工作流
For or when invoked internally:
/blog image generate <idea>针对命令或内部调用场景:
/blog image generate <idea>Step 1: Analyze Intent
步骤1:分析意图
Determine what the blog needs:
- Image type: Hero, inline, OG card, section divider?
- Blog topic: What is the article about?
- Style: Photorealistic, editorial, illustrated, minimal?
- Constraints: Brand colors, specific dimensions, platform format?
- Mood: Authoritative, inviting, dramatic, clean?
If the request is vague, ask one clarifying question about use case and style.
确定博客需求:
- 图像类型:首屏图、内联图、OG卡片、章节分隔图?
- 博客主题:文章内容是什么?
- 风格:写实风、社论风、插画风、极简风?
- 约束条件:品牌色、特定尺寸、平台格式?
- 氛围:权威感、亲和力、戏剧性、简洁感?
如果请求模糊,询问一个关于使用场景和风格的澄清问题。
Step 2: Select Domain Mode
步骤2:选择领域模式
Choose the expertise lens for the image:
| Mode | When to use | Prompt emphasis |
|---|---|---|
| Editorial | Blog headers, feature images, lifestyle | Styling, composition, publication references |
| Product | E-commerce posts, reviews, comparisons | Surface materials, studio lighting, clean BG |
| Landscape | Environmental backgrounds, travel, hero sections | Atmospheric perspective, depth layers, time of day |
| UI/Web | Tech blog icons, illustrations, diagrams | Clean vectors, flat design, exact colors |
| Infographic | Data-driven posts, processes, comparisons | Layout structure, hierarchy, accessible colors |
| Abstract | Pattern backgrounds, section dividers, decorative | Color theory, mathematical forms, textures |
Load for domain mode modifier libraries.
references/prompt-engineering-blog.md为图像选择专业视角:
| 模式 | 使用场景 | 提示词重点 |
|---|---|---|
| Editorial | 博客标题、特辑图片、生活方式内容 | 风格、构图、出版物参考 |
| Product | 电商文章、评测、对比内容 | 表面材质、影棚灯光、干净背景 |
| Landscape | 环境背景、旅行内容、首屏章节 | 大气透视、层次深度、时段 |
| UI/Web | 技术博客图标、插图、图表 | 简洁矢量图、扁平化设计、精准色彩 |
| Infographic | 数据驱动型文章、流程、对比内容 | 布局结构、层级、易读色彩 |
| Abstract | 图案背景、章节分隔图、装饰性图片 | 色彩理论、数学形态、纹理 |
加载获取领域模式修饰词库。
references/prompt-engineering-blog.mdStep 3: Construct the 6-Component Reasoning Brief
步骤3:构建6要素推理简报
Build the prompt as natural narrative paragraphs - NEVER as keyword lists:
- Subject - Who/what, with rich physical detail (textures, materials, scale)
- Action - What is happening, pose, gesture, movement, state
- Context - Environment, setting, time of day, season, weather
- Composition - Camera angle, shot type, framing, negative space, depth
- Lighting - Light source, quality, direction, color temperature, shadows
- Style - Art medium, aesthetic, film stock, reference artists/eras
Template for photorealistic blog images:
A photorealistic [shot type] of [subject with physical detail], [action/pose],
set in [environment with specifics]. [Lighting conditions] create [mood].
Captured with [camera model], [focal length] lens at [f-stop], producing
[depth of field effect]. [Color palette/grading notes]. Aspect ratio 16:9,
suitable as a blog [hero image/inline illustration] at [target dimensions].Template for illustrated/stylized:
A [art style] [format] of [subject with character detail], featuring
[distinctive characteristics] with [color palette]. [Line style] and
[shading technique]. Background is [description]. [Mood/atmosphere].将提示词构建为自然叙述段落——绝不要使用关键词列表:
- 主体:谁/什么,包含丰富的物理细节(纹理、材质、比例)
- 动作:正在发生的行为、姿势、手势、动作、状态
- 场景:环境、地点、时段、季节、天气
- 构图:拍摄角度、镜头类型、取景、留白、景深
- 光线:光源、光线质量、方向、色温、阴影
- 风格:艺术媒介、美学风格、胶片类型、参考艺术家/时代
写实风格博客图像模板:
A photorealistic [shot type] of [subject with physical detail], [action/pose],
set in [environment with specifics]. [Lighting conditions] create [mood].
Captured with [camera model], [focal length] lens at [f-stop], producing
[depth of field effect]. [Color palette/grading notes]. Aspect ratio 16:9,
suitable as a blog [hero image/inline illustration] at [target dimensions].插画/风格化图像模板:
A [art style] [format] of [subject with character detail], featuring
[distinctive characteristics] with [color palette]. [Line style] and
[shading technique]. Background is [description]. [Mood/atmosphere].Step 4: Set Aspect Ratio
步骤4:设置宽高比
Call BEFORE generating:
set_aspect_ratio| Blog Use Case | Ratio |
|---|---|
| Hero / Cover / OG | |
| Product shot / Square | |
| Section divider | |
| Vertical (stories) | |
生成前先调用:
set_aspect_ratio| 博客使用场景 | 比例 |
|---|---|
| 首屏/封面/OG图 | |
| 产品图/方形图 | |
| 章节分隔图 | |
| 竖版(故事类) | |
Step 5: Generate via MCP
步骤5:通过MCP生成
| MCP Tool | When |
|---|---|
| Always call first if ratio differs from 1:1 |
| New image from crafted prompt |
| Modify existing image |
| Iterative refinement / multi-turn sessions |
| Review generated images |
| Reset session context |
Model selection (use MCP tool if switching):
set_model- NB2 Flash (default): Best for most blog images - fast, 14 ratios, 4K, $0.067/img
- NB Pro: Use for hero images with text overlays (94% text accuracy) or highest quality - $0.134/img
- Original: Budget option at $0.039/img - 5 ratios, 1K max
Load for parameter details.
Load for model specs, pricing, and rate limits.
references/mcp-tools.mdreferences/gemini-models.md| MCP工具 | 使用时机 |
|---|---|
| 当比例与1:1不同时,务必先调用 |
| 根据精心构建的提示词生成新图像 |
| 修改现有图像 |
| 迭代优化/多轮会话 |
| 查看已生成图像 |
| 重置会话上下文 |
模型选择(如需切换,使用 MCP工具):
set_model- NB2 Flash(默认):适用于大多数博客图像——速度快,支持14种比例,4K分辨率,每张0.067美元
- NB Pro:适用于带文字叠加的首屏图(文字准确率94%)或最高质量需求——每张0.134美元
- Original:经济型选项,每张0.039美元——支持5种比例,最大1K分辨率
加载获取参数细节。
加载获取模型规格、定价和速率限制。
references/mcp-tools.mdreferences/gemini-models.mdStep 6: Post-Processing (when needed)
步骤6:后期处理(必要时)
After generation, resize/convert for blog use:
bash
undefined生成后,调整尺寸/格式以适配博客使用:
bash
undefinedResize to blog hero dimensions (1200x630)
调整为博客首屏图尺寸(1200x630)
magick input.png -resize 1200x630^ -gravity center -extent 1200x630 hero.png
magick input.png -resize 1200x630^ -gravity center -extent 1200x630 hero.png
Convert to WebP for web optimization
转换为WebP格式以优化网页性能
magick input.png -quality 85 output.webp
magick input.png -quality 85 output.webp
Convert to AVIF (smallest, modern)
转换为AVIF格式(体积最小,现代格式)
magick input.png -quality 80 output.avif
magick input.png -quality 80 output.avif
Crop to exact OG dimensions
裁剪为精确的OG图尺寸
magick input.png -resize 1200x630^ -gravity center -extent 1200x630 og-image.png
Check if `magick` (ImageMagick 7) is available. Fall back to `convert` if not.magick input.png -resize 1200x630^ -gravity center -extent 1200x630 og-image.png
检查`magick`(ImageMagick 7)是否可用。如果不可用,退而使用`convert`。Step 7: Deliver
步骤7:交付内容
Provide:
- Image path - where it was saved ()
~/Documents/nanobanana_generated/ - Crafted prompt - show the full Reasoning Brief (educational)
- Settings - model, aspect ratio, domain mode
- Alt text - descriptive sentence, 10-125 chars, topic keywords naturally
- Frontmatter snippet (for hero/OG images):
yaml
coverImage: "/path/to/generated-image.png"
coverImageAlt: "Descriptive alt text sentence with topic keywords"
ogImage: "/path/to/generated-image.png"- Refinement suggestions - 1-2 ideas if relevant
提供以下信息:
- 图像路径——保存位置()
~/Documents/nanobanana_generated/ - 精心构建的提示词——展示完整的推理简报(兼具教育意义)
- 设置参数——模型、宽高比、领域模式
- 替代文本(Alt text)——描述性句子,10-125字符,自然融入主题关键词
- 前置元数据片段(针对首屏/OG图):
yaml
coverImage: "/path/to/generated-image.png"
coverImageAlt: "包含主题关键词的描述性替代文本句子"
ogImage: "/path/to/generated-image.png"- 优化建议——1-2条相关建议(如有必要)
Edit Workflow
编辑工作流
For :
/blog image edit <path> <instructions>- Read the image path and edit instruction
- Enhance the instruction (never pass raw):
User says Claude crafts "remove background" Detailed edge-preserving background removal "make it warmer" Specific color temperature shift with preservation notes "add text" Font style, size, placement, contrast, readability notes "make it brighter" Increase exposure, lift shadows, maintain highlights "crop for social" Resize to 1200x630 with center-gravity crop - Call with enhanced instruction
gemini_edit_image - Return modified image path and description
针对命令:
/blog image edit <path> <instructions>- 读取图像路径和编辑指令
- 优化指令(绝不要直接传递原始指令):
用户表述 Claude优化后内容 "移除背景" 保留边缘细节的精准背景移除 "调暖色调" 特定色温调整,并保留关键区域色彩 "添加文字" 字体样式、大小、位置、对比度、可读性说明 "调亮画面" 提高曝光度、提亮阴影、保留高光细节 "裁剪适配社交平台" 调整为1200x630尺寸,居中裁剪 - 使用优化后的指令调用
gemini_edit_image - 返回修改后的图像路径和描述
Internal API (for blog-write / blog-rewrite)
内部API(供blog-write / blog-rewrite使用)
When invoked as a Task subagent from blog-write or blog-rewrite:
Input (provided by calling skill):
- : hero, inline, og, divider
image_type - : blog post topic/title
topic - : (optional) heading or section the image supports
section_context - : (optional) photorealistic, illustrated, editorial
style_preference - : (optional) number of images needed (default: 1)
count
Output (returned to calling skill):
markdown
undefined当作为任务子代理从blog-write或blog-rewrite调用时:
输入(由调用方提供):
- : hero, inline, og, divider
image_type - : 博客文章主题/标题
topic - :(可选)图像支持的标题或章节
section_context - :(可选)photorealistic, illustrated, editorial
style_preference - :(可选)需要生成的图像数量(默认:1)
count
输出(返回给调用方):
markdown
undefinedGenerated Image
Generated Image
- Path: ~/Documents/nanobanana_generated/image_timestamp.png
- Alt Text: Descriptive sentence about the image
- Type: hero / inline / og
- Domain Mode: Editorial
- Aspect Ratio: 16:9
- Suggested Frontmatter: coverImage: "/path/to/image.png" coverImageAlt: "Alt text here"
**Graceful fallback**: If MCP is unavailable, return immediately with no error.
The calling workflow continues with stock photos. Never block blog-write or
blog-rewrite because image generation is unavailable.- Path: ~/Documents/nanobanana_generated/image_timestamp.png
- Alt Text: 图像的描述性句子
- Type: hero / inline / og
- Domain Mode: Editorial
- Aspect Ratio: 16:9
- Suggested Frontmatter: coverImage: "/path/to/image.png" coverImageAlt: "替代文本内容"
**优雅降级**:如果MCP不可用,立即静默返回,不报错。调用工作流将继续使用库存图片。绝不要因图像生成不可用而阻塞blog-write或blog-rewrite流程。Alt Text Generation
替代文本(Alt Text)生成
For every generated image, create alt text following blog standards:
- Full descriptive sentence (not keyword list)
- 10-125 characters
- Include topic keywords naturally
- Describe what the image shows AND its relevance to the content
- For charts/infographics: include the key data point
Good:
Bad:
Marketing team analyzing AI search traffic data on a dashboard showing citation metricsSEO AI marketing blog optimization image为每一张生成的图像创建符合博客标准的替代文本:
- 完整的描述性句子(而非关键词列表)
- 10-125字符
- 自然融入主题关键词
- 描述图像内容及其与文章的相关性
- 针对图表/信息图:包含关键数据点
示例(好):
示例(差):
营销团队在仪表盘上分析AI搜索流量数据,展示引用指标SEO AI营销博客优化图片Setup
配置流程
For :
/blog image setup- Run (interactive)
python3 scripts/setup_image_mcp.py- Or: (non-interactive)
python3 scripts/setup_image_mcp.py --key YOUR_KEY - Default writes to (user-private, mode 0600)
~/.claude/settings.json - flag opts into project
--project(env-expansion only, refuses to write a literal key into a tracked file).mcp.json
- Or:
- Verify:
python3 scripts/validate_image_setup.py - Requires:
- Node.js 18+ (npx)
- Google AI API key (free at https://aistudio.google.com/apikey)
- The script pins the package to . Update the pin in
@ycse/nanobanana-mcp@1.1.1(constantsetup_image_mcp.py) when bumping.PINNED_PACKAGE
针对命令:
/blog image setup- 运行(交互式)
python3 scripts/setup_image_mcp.py- 或:(非交互式)
python3 scripts/setup_image_mcp.py --key YOUR_KEY - 默认写入(用户私有,权限0600)
~/.claude/settings.json - 选项会写入项目
--project(仅支持环境变量扩展,拒绝将明文密钥写入被追踪的文件).mcp.json
- 或:
- 验证配置:
python3 scripts/validate_image_setup.py - 依赖要求:
- Node.js 18+(npx)
- Google AI API密钥(可在https://aistudio.google.com/apikey免费获取)
- 脚本固定依赖包版本为。升级时需修改
@ycse/nanobanana-mcp@1.1.1中的常量setup_image_mcp.py。PINNED_PACKAGE
Safety Filter Auto-Rephrase
安全过滤器自动重写
When or is returned, do NOT give up. Auto-rephrase and retry:
IMAGE_SAFETYSAFETY- Identify the likely trigger (violence, public figures, NSFW-adjacent, or overly cautious filter)
- Rephrase using positive framing - describe what you WANT, not what to avoid
- If the subject is a person, make them generic (remove celebrity-like specifics)
- If the scene is dramatic, soften: "intense" → "focused", "battle" → "competition"
- Retry with the rephrased prompt (max 3 attempts before reporting to user)
Google acknowledged filters "became way more cautious than we intended" - benign prompts
are sometimes blocked. Persistence with rephrasing usually succeeds.
当返回或时,不要放弃。自动重写提示词并重试:
IMAGE_SAFETYSAFETY- 识别可能的触发因素(暴力、公众人物、类NSFW内容,或过度谨慎的过滤器)
- 使用积极表述重写——描述你想要的内容,而非要避免的内容
- 如果主体是人物,改为通用形象(移除类似名人的细节)
- 如果场景过于戏剧化,适当软化:"激烈的"→"专注的","战斗"→"竞争"
- 使用重写后的提示词重试(最多3次,若仍失败则告知用户)
谷歌承认过滤器"变得比预期的谨慎得多"——良性提示词有时会被拦截。坚持重写通常会成功。
Edit, Don't Re-roll
优先编辑,而非重新生成
If an image is 80% correct, use for conversational editing rather than
regenerating from scratch. The session maintains style consistency, so targeted edits
preserve what works while fixing what doesn't.
gemini_chatWhen to edit vs regenerate:
- Color slightly off → Edit ("shift the color temperature warmer")
- Wrong composition entirely → Regenerate with revised brief
- Good scene but wrong lighting → Edit ("change to golden hour lighting from the left")
- Missing a detail → Edit ("add a steaming coffee cup on the desk")
如果图像80%符合要求,使用进行会话式编辑,而非从头重新生成。会话会保持风格一致性,针对性编辑能保留现有优点并修正不足。
gemini_chat编辑与重新生成的选择时机:
- 颜色略有偏差 → 编辑("将色温调暖")
- 构图完全错误 → 使用修订后的简报重新生成
- 场景合适但光线不佳 → 编辑("改为左侧来的黄金时段光线")
- 缺少某个细节 → 编辑("在桌上添加一杯冒着热气的咖啡")
Error Handling
错误处理
| Error | Resolution |
|---|---|
| MCP not configured | Run |
| API key invalid | New key at https://aistudio.google.com/apikey |
| Rate limited (429) | Wait 60s, retry. Free tier: ~5-15 RPM / ~20-500 RPD (varies by model and billing) |
| Auto-rephrase (see above) - Layer 2 filter, non-configurable |
| Content policy violation - topic is blocked. Non-retryable. |
| Rephrase prompt - Layer 1 filter |
| Vague request | Ask one clarifying question before generating |
| Poor quality | Review Reasoning Brief - likely missing lighting (biggest quality differentiator) |
| MCP unavailable (internal call) | Return silently - calling workflow uses stock photos |
| 错误 | 解决方法 |
|---|---|
| MCP未配置 | 运行 |
| API密钥无效 | 在https://aistudio.google.com/apikey获取新密钥 |
| 速率限制(429) | 等待60秒后重试。免费额度:约5-15次/分钟 / 20-500次/天(因模型和计费方式而异) |
| 自动重写提示词(见上文)——二级过滤器,不可配置 |
| 违反内容政策——主题被拦截,不可重试 |
| 重写提示词——一级过滤器 |
| 请求模糊 | 生成前询问一个澄清问题 |
| 图像质量差 | 检查推理简报——可能缺少光线描述(影响质量的关键因素) |
| MCP不可用(内部调用) | 静默返回——调用工作流使用库存图片 |
Reference Documentation
参考文档
Load on-demand - do NOT load all at startup:
- - Domain modes, 6-component system, blog templates
references/prompt-engineering-blog.md - - Model specs, rate limits, aspect ratios, pricing
references/gemini-models.md - - MCP tool parameters and response formats
references/mcp-tools.md
按需加载——不要在启动时全部加载:
- ——领域模式、6要素系统、博客模板
references/prompt-engineering-blog.md - ——模型规格、速率限制、宽高比、定价
references/gemini-models.md - ——MCP工具参数和响应格式
references/mcp-tools.md