关于 gemini-image-gen
通过 Chrome 中的 Gemini 生成和编辑图像的技能,面向需要自动化图像创作的用户。它涵盖浏览器操作、提示词构建、参考图上传及保存生成文件。
主要功能
- 01通过 Chrome 中的 Gemini 生成图像
- 02上传参考图
- 03指导提示词构建
- 04编辑并放大生成的图像
- 05下载并移动图像文件
适用场景
- 01根据文本提示创建图像
- 02根据参考图片生成图像
- 03通过后续提示修改图像
MCP 相关
使用 Chrome MCP 工具导航并操作 Gemini 网页界面。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ maystudios/ claude-skills --skill gemini-image-gen安装后在 Claude Code 中输入/gemini-image-gen确认已加载。
附带文件references/prompting-guide.md
详细介绍
通过 Chrome 使用 Gemini 生成图像
通过 Chrome 浏览器自动化,使用 Google Gemini 网页界面生成图像。基于 Nano Banana / Gemini 3 图像生成模型。
前提条件
- 已安装并启用 Claude-in-Chrome 扩展程序的 Chrome 浏览器
- 用户必须已登录 https://gemini.google.com 上的 Google 账号
- 可使用 Chrome MCP 工具(
mcp__claude-in-chrome__*)
工具映射
| 操作 | MCP 工具 |
|---|---|
| 获取标签页上下文 | mcp__claude-in-chrome__tabs_context_mcp |
| 创建新标签页 | mcp__claude-in-chrome__tabs_create_mcp |
| 导航至 URL | mcp__claude-in-chrome__navigate |
| 点击、输入、截屏、悬停、滚动、等待 | mcp__claude-in-chrome__computer |
| 按描述查找元素 | mcp__claude-in-chrome__find |
| 读取页面无障碍树 | mcp__claude-in-chrome__read_page |
| 设置表单值 | mcp__claude-in-chrome__form_input |
| 上传参考图像 | mcp__claude-in-chrome__upload_image |
| 提取页面文本 | mcp__claude-in-chrome__get_page_text |
工作流
步骤 1:初始化浏览器会话
1. Call tabs_context_mcp to discover existing tabs
2. Call tabs_create_mcp to create a fresh tab
3. Navigate to https://gemini.google.com/app
4. Take a screenshot to verify the page loaded
步骤 2:启用图像生成功能并开始新聊天
1. Use find to locate the "New chat" button (top-left area / sidebar), then click it with computer
2. Take a screenshot with computer to confirm the new chat is open
3. Use find to locate the "Tools" or settings area in the chat interface
4. Enable "Image generation" / "Bilderstellung" tool by clicking it
5. Take a screenshot to confirm image generation is enabled
步骤 3:上传参考图像(如有)
如果用户提供了参考图像(最多支持 14 张),请在提交提示词之前上传:
1. Use find to locate the attachment/upload button in the chat input area
2. For each reference image:
a. Click the upload button with computer
b. Use upload_image to upload the file to the file input or drop zone
3. Supported formats: PNG, JPEG, WebP, HEIC, HEIF
4. Verify uploads appear in the chat input area via screenshot
步骤 4:构建并提交提示词
使用下面的结构化框架构建提示词,然后输入并提交。
提示词构建公式:
文本生成图像(无参考图像):
[Subject] + [Action] + [Location/Context] + [Composition] + [Style]
多模态生成(有参考图像):
[Reference images] + [Relationship instruction] + [New scenario]
用户指定以下内容时,请在提示词中加入:
- **分辨率:**自然地附上所需分辨率,例如“以 4K 分辨率生成此图”或“创作一张 2K 图像……”
- 可选:0.5K(512px)、1K、2K、4K
- **宽高比:**指定比例,例如“宽高比为 16:9”
- 可选:1:1、3:2、2:3、3:4、4:3、4:5、5:4、9:16、16:9、21:9、1:4、4:1、1:8、8:1
- **风格:**使用提示词指南中的摄影/电影风格用语
提交:
1. Use find to locate the prompt input field (textarea / chat input)
2. Type the constructed prompt using computer action "type"
3. Press Enter or click the send button via computer to submit
4. Wait for the image to generate (use computer wait action, 15-30 seconds typical, up to 60s for 4K)
5. Take a screenshot with computer to verify the image was generated
步骤 5:下载生成的图像
1. Take a screenshot with computer to see the generated image
2. Hover over the generated image using computer action "hover" to reveal download controls
3. Look for "Download original size" / "Originalgröße herunterladen" button
(appears top-right corner of the image on hover)
4. Click the download button with computer
5. Wait 3-5 seconds (computer wait action) for the download to complete
6. The file will be saved to the user's Downloads folder
步骤 6:移动下载的文件
1. Find the most recently downloaded file in the Downloads folder:
ls -t ~/Downloads/ | head -5
2. Move the file to the user's specified destination using Bash:
mv ~/Downloads/filename.png "/desired/destination/filename.png"
3. Report the final file location to the user
提示词优化指南
用户提供基础提示词时,按照以下原则进行优化:
- **具体明确:**补充主体、光线和构图等具体细节
- **使用正向表述:**描述你想要的内容,而非不想要的内容(“空旷的街道”,而非“没有汽车”)
- **控制镜头:**使用“低角度”“航拍视角”“微距镜头”等摄影术语
- 以有力的动词开头:“创作”“生成”“设计”“拍摄”
- **以叙述方式描述:**撰写场景描述,而非关键词列表
**光线术语:**三点柔光箱、明暗对照法、黄金时刻逆光、伦勃朗光 **镜头术语:**GoPro(畸变/沉浸感)、Fujifilm(色彩科学)、微距镜头(细节)、广角镜头(规模感) 胶片/色彩:“1980 年代彩色胶片,略带颗粒感”、“电影感的低饱和青绿色调”、“高饱和度编辑风格” **材质表现:**指定纹理——“海军蓝粗花呢”,而不只是“夹克”;“饰有银箔刻纹的精致精灵板甲”,而不只是“盔甲”
图像中的文字渲染:
- 将文字放在引号中:“生日快乐”
- 指定字体:“粗体白色无衬线字体”或“Century Gothic 12px”
- 支持 10 种以上语言的多语言文字
分辨率和纵横比快速参考
| 分辨率 | 像素 | 最适合 |
|---|---|---|
| 0.5K | ~512px | 快速草稿、缩略图 |
| 1K | ~1024px | 网页使用、社交媒体 |
| 2K | ~2048px | 高质量印刷品、演示文稿 |
| 4K | ~4096px | 大幅印刷品、专业用途 |
| 纵横比 | 用途 |
|---|---|
| 1:1 | 社交媒体帖子、个人资料图片 |
| 16:9 | 宽屏、YouTube 缩略图、演示文稿 |
| 9:16 | 手机壁纸、Instagram/TikTok 快拍 |
| 3:2 | 摄影标准比例 |
| 4:3 | 经典显示比例 |
| 21:9 | 超宽屏、电影画幅 |
| 4:5 | Instagram 竖版照片 |
| 1:4 / 4:1 | 横幅、全景图 |
| 1:8 / 8:1 | 超长横幅 |
提示词框架
如需了解涵盖全部五种框架(图像生成、图像编辑、实时网页搜索、文本渲染、创意指导)的详细提示词策略,请参阅随附参考资料:
参考资料: references/prompting-guide.md —— 全面的提示词指南,包含各框架的示例
图像编辑(后续提示词)
生成图像后,用户可以在同一聊天中请求编辑:
- 局部重绘:“从背景中移除这个人”(通过文本进行语义遮罩)
- 风格迁移:“将其重新创作为水彩风格”
- 添加元素:“在场景中添加一把红色雨伞”
- 放大:“将其放大到 4K”
明确说明要保留的内容:“其他所有内容都保持完全不变,只更改……”
错误处理
- 如果页面无法加载:重试导航,并检查互联网连接
- 如果图像生成失败:简化提示词,删除复杂指令
- 如果下载按钮没有出现:尝试滚动页面,更精确地将鼠标悬停在图像上
- 如果 10 秒后文件仍未出现在 Downloads 中:使用
ls -t ~/Downloads/ | head -5检查 - 如果找不到工具/图像生成切换项:截取屏幕截图,并查找其他 UI 路径
备注
- 所有 Gemini 生成的图像都包含 C2PA 内容凭证和 SynthID 水印
- 这些模型的知识截止时间为 2025 年 1 月,但可以使用实时网页搜索
- 最大输入:131,072 个 token(Flash)/ 65,536 个 token(Pro)
- 两种模型的最大输出均为 32,768 个 token
- 参考资料支持的输入文件类型:PNG、JPEG、WebP、HEIC、HEIF
- 也支持 PDF 和文本文件输入(最大 50MB)