upscale-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUpscale Image
图片放大
Upscale images using Imagen on Vertex AI.
使用Vertex AI上的Imagen进行图片放大。
Prerequisites
前置条件
This skill requires Vertex AI credentials (not GEMINI_API_KEY).
此Skill需要Vertex AI凭证(而非GEMINI_API_KEY)。
Check Current Setup
检查当前配置
bash
echo "Project: ${GOOGLE_CLOUD_PROJECT:-NOT SET}"
gcloud auth application-default print-access-token &>/dev/null && echo "Auth: OK" || echo "Auth: NOT CONFIGURED"bash
echo "Project: ${GOOGLE_CLOUD_PROJECT:-NOT SET}"
gcloud auth application-default print-access-token &>/dev/null && echo "Auth: OK" || echo "Auth: NOT CONFIGURED"First-Time Setup
首次配置
If credentials are not configured, guide the user through these steps:
-
Get a Google Cloud Project
- Go to: https://console.cloud.google.com/projectcreate
- Create a new project or use an existing one
- Note the Project ID (not the project name)
-
Enable Vertex AI API
- Go to: https://console.cloud.google.com/apis/library/aiplatform.googleapis.com
- Click "Enable"
-
Enable Billing
- Go to: https://console.developers.google.com/billing/enable?project=YOUR_PROJECT_ID
- Link a billing account
-
Install gcloud CLI (if not installed)
- Go to: https://cloud.google.com/sdk/docs/install
- Or on macOS:
brew install google-cloud-sdk
-
Authenticatebash
gcloud auth application-default loginThis opens a browser for Google sign-in. -
Set Environment Variablebash
echo 'export GOOGLE_CLOUD_PROJECT=your-project-id' >> ~/.zshenv
如果未配置凭证,请引导用户完成以下步骤:
-
获取Google Cloud项目
- 访问:https://console.cloud.google.com/projectcreate
- 创建新项目或使用现有项目
- 记录项目ID(而非项目名称)
-
启用Vertex AI API
-
启用账单功能
-
安装gcloud CLI(若未安装)
- 访问:https://cloud.google.com/sdk/docs/install
- 或在macOS上执行:
brew install google-cloud-sdk
-
身份验证bash
gcloud auth application-default login此操作会打开浏览器进行Google登录。 -
设置环境变量bash
echo 'export GOOGLE_CLOUD_PROJECT=your-project-id' >> ~/.zshenv
Usage
使用方法
bash
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts <input-image> [options]bash
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts <input-image> [options]Options
选项
- - Upscale factor (default: x2)
--factor <x2|x4> - - Output format
--format <png|jpeg|webp> - - JPEG quality (1-100)
--quality <n> - - Output path
--output <path> - - Google Cloud project (overrides env var)
--project <id> - - Vertex AI location (default: us-central1)
--location <region>
- - 放大倍数(默认值:x2)
--factor <x2|x4> - - 输出格式
--format <png|jpeg|webp> - - JPEG质量(1-100)
--quality <n> - - 输出路径
--output <path> - - Google Cloud项目(覆盖环境变量)
--project <id> - - Vertex AI区域(默认值:us-central1)
--location <region>
Examples
示例
bash
undefinedbash
undefined2x upscale
2倍放大
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg
4x upscale
4倍放大
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg --factor x4
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg --factor x4
Upscale and save as PNG
放大并保存为PNG格式
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg --factor x4 --format png --output hires.png
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg --factor x4 --format png --output hires.png
Specify project explicitly
显式指定项目
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg --project my-gcp-project --factor x4
undefinedbun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg --project my-gcp-project --factor x4
undefinedContext Discipline
上下文规范
Do not read generated images back into context. The script outputs only the file path. Ask the user to visually inspect the result. Upscaled images are especially large (2x/4x resolution) and will quickly exhaust the context window.
请勿将生成的图片重新读入上下文。 脚本仅输出文件路径。请让用户自行视觉检查结果。放大后的图片体积特别大(2倍/4倍分辨率),会迅速耗尽上下文窗口。
Model
模型
Uses via Vertex AI upscaleImage API.
imagen-3.0-generate-002通过Vertex AI的upscaleImage API使用模型。
imagen-3.0-generate-002Why Vertex AI?
为什么选择Vertex AI?
The Imagen upscaling API is only available through Vertex AI, not the standard Gemini API. This is a Google limitation - the method in the @google/genai SDK only works with Vertex AI backend.
upscaleImageImagen放大API仅通过Vertex AI提供,而非标准的Gemini API。这是Google的限制——@google/genai SDK中的方法仅适用于Vertex AI后端。
upscaleImage