upscale-image

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Upscale 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:
  1. Get a Google Cloud Project
  2. Enable Vertex AI API
  3. Enable Billing
  4. Install gcloud CLI (if not installed)
  5. Authenticate
    bash
    gcloud auth application-default login
    This opens a browser for Google sign-in.
  6. Set Environment Variable
    bash
    echo 'export GOOGLE_CLOUD_PROJECT=your-project-id' >> ~/.zshenv
如果未配置凭证,请引导用户完成以下步骤:
  1. 获取Google Cloud项目
  2. 启用Vertex AI API
  3. 启用账单功能
  4. 安装gcloud CLI(若未安装)
  5. 身份验证
    bash
    gcloud auth application-default login
    此操作会打开浏览器进行Google登录。
  6. 设置环境变量
    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

选项

  • --factor <x2|x4>
    - Upscale factor (default: x2)
  • --format <png|jpeg|webp>
    - Output format
  • --quality <n>
    - JPEG quality (1-100)
  • --output <path>
    - Output path
  • --project <id>
    - Google Cloud project (overrides env var)
  • --location <region>
    - Vertex AI location (default: us-central1)
  • --factor <x2|x4>
    - 放大倍数(默认值:x2)
  • --format <png|jpeg|webp>
    - 输出格式
  • --quality <n>
    - JPEG质量(1-100)
  • --output <path>
    - 输出路径
  • --project <id>
    - Google Cloud项目(覆盖环境变量)
  • --location <region>
    - Vertex AI区域(默认值:us-central1)

Examples

示例

bash
undefined
bash
undefined

2x 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
undefined
bun run ${CLAUDE_PLUGIN_ROOT}/skills/upscale-image/scripts/upscale.ts photo.jpg --project my-gcp-project --factor x4
undefined

Context 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
imagen-3.0-generate-002
via Vertex AI upscaleImage API.
通过Vertex AI的upscaleImage API使用
imagen-3.0-generate-002
模型。

Why 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
upscaleImage
method in the @google/genai SDK only works with Vertex AI backend.
Imagen放大API仅通过Vertex AI提供,而非标准的Gemini API。这是Google的限制——@google/genai SDK中的
upscaleImage
方法仅适用于Vertex AI后端。