关于 gemini-image
gemini-image 是一项通过 CamoFox 命令行在 Gemini 中生成并下载图像的技能,面向需要自动化图像生成流程的用户。它涵盖登录、会话复用、生成及文件获取。
主要功能
- 01通过 CamoFox CLI 操作 Gemini
- 02保存并复用登录会话
- 03提交图像描述生成图片
- 04检查并下载生成的图片
适用场景
- 01使用已保存的会话生成图像
- 02完成 Google 登录与双重验证
- 03从 Gemini 获取生成的图像文件
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ redf0x1/ camofox-browser --skill gemini-image安装后在 Claude Code 中输入/gemini-image确认已加载。
附带文件references/workflow-reference.md
详细介绍
Gemini 图像生成技能(CLI)
仅使用 CamoFox CLI 命令执行 Gemini 图像生成流程。仅在通过本地 CamoFox 下载 API 获取下载文件时使用 curl。
1. 前置条件
- CamoFox 服务必须在端口
9377上运行。 - 拥有可访问 Gemini 的 Google 账号。
- 首次登录需要电子邮件/密码,并在手机上批准 2FA。
- 首次登录后,保存并重复使用会话配置文件。
2. 快速开始(快速路径 — 已通过身份验证)
已有有效的 Gemini 会话保存时:
以下所有命令均假设使用 --user gemini。在多会话场景中,请显式添加该参数。
# Load saved session and open Gemini
camofox open https://gemini.google.com/app --user gemini
# Load saved profile
camofox session load <profile-name> --user gemini
# Verify auth (check for profile avatar, no "Sign in" button)
camofox snapshot --user gemini
# Type image prompt
camofox type <prompt-ref> "your image description here" --user gemini
# Submit prompt
camofox press Enter --user gemini
# Wait for image generation to complete (15-180 seconds)
camofox wait 'mat-icon[fonticon="download"]' --timeout 180000 --user gemini
# Download the generated image
camofox click 'mat-icon[fonticon="download"]' --user gemini
# Cleanup
camofox close --user gemini
3. 身份验证流程
步骤 3.1:检查身份验证状态
camofox open https://gemini.google.com/app --user gemini
camofox snapshot --user gemini
# Look for: "Sign in" button -> NOT authenticated
# Look for: Greeting text "Xin chào..." -> authenticated
步骤 3.2:登录(如有需要)
# Navigate to Google login
camofox navigate https://accounts.google.com --user gemini
# Enter email
camofox fill '[e1]="[email protected]"' --user gemini
# OR
camofox type e1 "[email protected]" --user gemini
camofox click e4 --user gemini # Next button
# Wait for password page
camofox wait 'input[type="password"]' --user gemini
camofox snapshot --user gemini
# Enter password
camofox type e2 "password" --user gemini
camofox click e4 --user gemini # Next button
安全提示: 对于生产工作流,请将凭据存储在 CamoFox Auth Vault 中:
camofox auth save google-gemini # Follow interactive prompts to save credentials securely camofox auth load google-gemini --user gemini
步骤 3.3:2FA(推送通知)
输入密码后,Google 可能会提示进行 2FA:
- 推送通知:用户在手机应用中点按“Yes”。
- 等待重定向:
camofox wait 'a[href*="myaccount.google.com"]' --timeout 90000 --user gemini
- 或等待 URL 从
accounts.google.com更改:
camofox wait navigation --timeout 90000 --user gemini
步骤 3.4:保存会话
camofox session save <profile-name> --user gemini
# Reuse next time with: camofox session load <profile-name> --user gemini
4. 图像生成
# Navigate to Gemini (if not already there)
camofox navigate https://gemini.google.com/app --user gemini
# Snapshot to find prompt input ref
camofox snapshot --user gemini
# Prompt textbox is typically the main textarea element
# Type your image description
camofox type <prompt-ref> "Generate an image of a cute red fox wearing sunglasses in digital art style" --user gemini
# Submit the prompt
camofox press Enter --user gemini
# Wait for generation to complete (15-180 seconds)
# The download button appears when generation is done
camofox wait 'mat-icon[fonticon="download"]' --timeout 180000 --user gemini
# Verify the result
camofox snapshot --user gemini
# Key refs after generation:
# - Download button (mat-icon fonticon="download")
# - Like (mat-icon fonticon="thumb_up")
# - Dislike (mat-icon fonticon="thumb_down")
# - Redo
# - Share
5. 下载生成的图像
# Click download button (locale-independent CSS selector)
camofox click 'mat-icon[fonticon="download"]' --user gemini
# Check download status
camofox downloads --format json --user gemini
# Parse `downloadId` from JSON output (for example with `jq -r '.[0].id'`)
# Retrieve the file via REST API
# The click response or downloads command shows the download ID
curl -o "generated-image.png" "http://localhost:9377/downloads/<download-id>/content?userId=gemini"
# Cleanup
camofox close --user gemini
6. 提示与最佳实践
- 重复使用会话:登录后务必保存配置文件。每次运行前加载配置文件,以跳过登录。
- 不依赖区域设置的选择器:使用
mat-icon[fonticon="..."],而不是文本标签。 - 等待而非休眠:使用带 CSS 选择器的
camofox wait,不要使用固定延迟。 - 操作后重新获取快照:导航/交互后,元素引用(
eN)会变化。 - 图像提示词:尽可能详细地描述;Gemini 在提示词详细时表现更好。
- 速率限制:免费版有每日图像生成次数限制。达到限制后,请等待或切换账号。
7. 错误恢复
| 错误 | 解决方案 |
|---|---|
| 加载会话后仍显示“Sign in” | 会话已过期(24-48h)。使用电子邮件/密码和 2FA 重新登录 |
wait 等待下载按钮超时 | 图像生成可能失败。运行 camofox snapshot 并检查错误文本 |
| “can't create it right now” | 尚未通过身份验证。重新检查身份验证状态并再次登录 |
| “Image Generation Limit Reached” | 已达到每日限额。等待 24h 或使用其他账号 |
TAB_NOT_FOUND | 标签页已失效。使用 camofox open 打开新标签页 |
type 无法输入文本 | Gemini 可能使用自定义编辑器。备用方案:camofox eval 'document.querySelector(".ql-editor").innerHTML = "prompt"' |
8. 已验证的测试结果
- 账号:
[email protected](User) - 配置文件:
gemini-sky(52 个 Cookie) - 测试提示词:
Generate an image of a cute red fox wearing sunglasses in digital art style - 结果:
8.1MB PNG(Gemini_Generated_Image_ecu3ujecu3ujecu3.png) - 生成时间:
~30 秒 - 下载方式:
click mat-icon[fonticon="download"]
评论
支持 Markdown