
image-edit
在 RunComfy 上編輯圖片 — 此技能是一個智慧路由器,會根據使用者的意圖,從 RunComfy 目錄中選出最合適的編輯模型。支援 Nano Banana Edit(批次最多 20 張、預設保留人物身分)、OpenAI GPT Image 2 Edit(多語言圖內文字改寫、多參考合成、版面精準調整)、Flux Kontext Pro(單張參考、高保真局部編輯)或 Z-Image Turbo Inpaint(遮罩驅動的精確區域編輯)。內建每個模型的提示詞模式,讓技能能產出更精準的編輯結果,不必浪費疊代次數在錯誤的模型上。透過本機 RunComfy CLI 執行 `runcomfy run <vendor>/<model>/edit`。觸發關鍵字包括「image edit」、「edit image」、「image-to-image」、「i2i」、「swap background」、「remove object」、「rewrite headline」,或任何明確要求編輯單張或批次圖片的指令。
Edit images on RunComfy — this skill is a smart router that matches the user's intent to the right edit model in the RunComfy catalog. Picks Nano Banana Edit (batch up to 20, identity-preserving default), OpenAI GPT Image 2 Edit (multilingual in-image text rewrite, multi-ref composition, layout precision), Flux Kontext Pro (single-ref high-fidelity local edit), or Z-Image Turbo Inpaint (mask-driven precise region edit). Bundles each model's documented prompting patterns so the skill gets sharper edits without burning iterations on the wrong model. Calls `runcomfy run <vendor>/<model>/edit` through the local RunComfy CLI. Triggers on "image edit", "edit image", "image-to-image", "i2i", "swap background", "remove object", "rewrite headline", or any explicit ask to edit a single or batch of images.
Image Edit — Pro Pack on RunComfy
runcomfy.com · Nano Banana Edit · GPT Image 2 Edit · Flux Kontext · Z-Image Inpaint · GitHub
圖片編輯,依意圖路由。 此技能不將你限制在單一模型——它會根據使用者實際需求,從 RunComfy 目錄中選出最合適的編輯模型:批次保留身分、多語言文字改寫、單次精準編輯,或遮罩驅動的區域替換。
npx skills add agentspace-so/runcomfy-skills --skill image-edit -g
根據使用者意圖選擇正確模型
| 使用者意圖 | 模型 | 原因 |
|---|---|---|
| 批次編輯 1–20 張圖片,風格一致(SKU 圖庫、A/B 變體) | Nano Banana Edit | 每次呼叫最多 20 張輸入圖片;鎖定長寬比與解析度以維持系列一致性 |
| 替換背景,保留主體身分 | Nano Banana Edit | 在「保持 X 不變」提示下,身分保留能力強 |
| 使用空間語言進行局部物件移除/新增(「左邊的物體」、「右上角」) | Nano Banana Edit | 能正確處理方向性空間範圍 |
| 多語言/非拉丁文字圖內文字改寫(日文假名、西里爾字母、阿拉伯文) | GPT Image 2 Edit | 多語言排版能力同類最強 |
| 多參考合成(主體來自圖1、場景來自圖2、色調來自圖3) | GPT Image 2 Edit | 編號參考能正確引導線索 |
| 版面精準重新定位(「將標題從右上角移到中下方」) | GPT Image 2 Edit | 方向性語言在版面層級被正確處理 |
| 跨翻譯標題變體的身分保留 | GPT Image 2 Edit | 同一來源素材→多語言變體,身分穩定 |
| 單次精準局部編輯(「她現在拿著一把橘色雨傘」) | Flux Kontext Pro | 單參考單指令,高保真保留 |
| 遮罩驅動物件移除(電線、浮水印、干擾物) | Z-Image Turbo Inpaint | 需遮罩,強度可調,邊緣一致 |
| 遮罩驅動區域替換(使用遮罩完整更換背景) | Z-Image Turbo Inpaint | 高強度 + 乾淨遮罩 = 乾淨替換 |
| 未指定時的預設 | Nano Banana Edit | 最靈活,支援單張與批次 |
代理程式會讀取此表格,分類使用者意圖,並選用下方對應的子章節。
前置需求
- RunComfy CLI —
npm i -g @runcomfy/cli - RunComfy 帳號 —
runcomfy login。 - CI / 容器 — 設定
RUNCOMFY_TOKEN=<token>。
路由 1:Nano Banana Edit — 一般編輯與批次預設
模型:google/nano-banana-2/edit
結構
| 欄位 | 型別 | 必填 | 預設值 | 備註 |
|---|---|---|---|---|
prompt |
string | 是 | — | 先說明保留目標,再說明變更內容。 |
image_urls |
array | 是 | — | 1–20 個可公開存取的 HTTPS URL。 |
number_of_images |
int | 否 | 1 | 每次呼叫輸出 1–4 張。 |
aspect_ratio |
enum | 否 | auto |
auto 跟隨輸入;批次一致性請鎖定。 |
resolution |
enum | 否 | 1K |
0.5K / 1K / 2K / 4K。 |
output_format |
enum | 否 | png |
png / jpeg / webp。 |
seed |
int | 否 | — | 可重現性。 |
enable_web_search |
bool | 否 | false | 基於網路的編輯(額外延遲)。 |
執行
runcomfy run google/nano-banana-2/edit \
--input '{
"prompt": "Keep the subject identity, pose, and clothing unchanged. Convert the background into a rainy neon cyberpunk street.",
"image_urls": ["https://.../portrait.jpg"]
}' \
--output-dir <absolute/path>
批次(鎖定長寬比 + 解析度):
runcomfy run google/nano-banana-2/edit \
--input '{
"prompt": "Replace the watermark in the bottom-right with the text \"AURA\" in clean white sans-serif. Keep everything else exactly as in the input.",
"image_urls": ["https://.../sku-1.jpg", "https://.../sku-2.jpg", "https://.../sku-3.jpg"],
"aspect_ratio": "1:1",
"resolution": "1K"
}' \
--output-dir <absolute/path>
提示技巧
- 先保留後變更:
"Keep [identity / pose / brand / framing] unchanged."再說明變更。 - 空間範圍:「僅背景」、「左邊的物體」、「右上角象限」——具體位置會被正確處理。
- 批次一致性:鎖定整個批次的
aspect_ratio和resolution。 - 小步疊代:將複合編輯拆分為多次較短的處理。
路由 2:GPT Image 2 Edit — 多語言文字 + 多參考合成
模型:openai/gpt-image-2/edit
結構
| 欄位 | 型別 | 必填 | 預設值 | 備註 |
|---|---|---|---|---|
prompt |
string | 是 | — | 編輯指令;先說明保留項目。 |
images |
string[] | 是 | — | 最多 10 個 HTTPS URL。第一個為主圖,其餘為輔助。 |
size |
enum | 否 | auto |
auto、1024_1024、1024_1536、1536_1024。僅限這些。 |
執行
多語言文字改寫:
runcomfy run openai/gpt-image-2/edit \
--input '{
"prompt": "Keep the photograph, layout, and brand mark exactly as in the input. Replace only the in-image headline. The new headline reads \"今日のおすすめ\" in bold Japanese kana, same position and font weight.",
"images": ["https://.../poster-en.jpg"]
}' \
--output-dir <absolute/path>
多參考合成:
runcomfy run openai/gpt-image-2/edit \
--input '{
"prompt": "Compose subject from image 1 into the room from image 2. Match the lighting and color palette of image 2. Keep image 1 subject identity unchanged.",
"images": ["https://.../subject.jpg", "https://.../room.jpg"]
}' \
--output-dir <absolute/path>
提示技巧
- 精確引用圖內文字。 對非拉丁文字標示字體名稱:
"Japanese kana"、"Cyrillic"、"Arabic right-to-left"。 - 多參考編號:
"subject from image 1, lighting from image 2"。 - 方向性版面語言:
"move the headline from top-right to bottom-center"、"replace the watermark in the bottom-right"。 size: "auto"保留輸入比例——除非編輯會改變構圖,否則建議使用。
路由 3:Flux Kontext Pro — 單次精準局部編輯
模型:blackforestlabs/flux-1-kontext/pro/edit
結構(精簡版)
| 欄位 | 型別 | 必填 | 備註 |
|---|---|---|---|
prompt |
string | 是 | 一個陳述式編輯指令。 |
image |
string | 是 | 單張來源圖片 URL。 |
aspect_ratio |
enum | 否 | 從支援的 W:H 值中選取。 |
seed |
int | 否 | 可重現性。 |
僅限單張圖片——無陣列。如需多張圖片流程,請使用路由 1(Nano Banana Edit)。
執行
runcomfy run blackforestlabs/flux-1-kontext/pro/edit \
--input '{
"prompt": "Keep the person'\''s face, pose, and clothing unchanged. Add an orange umbrella in her left hand and a slight smile.",
"image": "https://.../portrait.jpg"
}' \
--output-dir <absolute/path>
提示技巧
- 一個陳述式指令。 「她現在拿著一把橘色雨傘並微笑」——命令式,單一變更。
- 先保留後變更。 以
"Keep [unchanged elements]"開頭,再說明變更。 - 小步疊代。 複合編輯在單次處理中容易偏移;請拆分為連續多次處理。
路由 4:Z-Image Turbo Inpaint — 遮罩驅動精確區域編輯
模型:tongyi-mai/z-image/turbo/inpainting
結構
| 欄位 | 型別 | 必填 | 備註 |
|---|---|---|---|
prompt |
string | 是 | 要填入/替換的內容;對未遮罩區域的保留限制。 |
image |
string | 是 | 來源圖片 URL。 |
mask_image |
string | 是 | 灰階遮罩 URL(白色 = 修補區域,黑色 = 保留區域)。 |
strength |
float | 否 | 0.3–0.6 修飾,0.7–1.0 完整替換。 |
control_scale |
float | 否 | 0.6–0.9 典型值。 |
aspect_ratio |
enum | 否 | W:H 輸出比例。 |
seed |
int | 否 | 可重現性。 |
執行
物件移除(低強度):
runcomfy run tongyi-mai/z-image/turbo/inpainting \
--input '{
"prompt": "Remove overhead cables; preserve rooflines and sky gradient; thin clean sky.",
"image": "https://.../street.jpg",
"mask_image": "https://.../cables-mask.png",
"strength": 0.5,
"control_scale": 0.8
}' \
--output-dir <absolute/path>
區域替換(高強度):
runcomfy run tongyi-mai/z-image/turbo/inpainting \
--input '{
"prompt": "Replace busy backdrop with smooth light gray studio paper; mask background only.",
"image": "https://.../product.jpg",
"mask_image": "https://.../bg-mask.png",
"strength": 0.9
}' \
--output-dir <absolute/path>
提示技巧
- 遮罩 URL 為必填——灰階,白色 = 修補區域,黑色 = 保留區域。遮罩邊緣輕微模糊(1–3px)比銳利二值化效果更好。
- 依意圖調整強度:
0.3–0.5用於修飾/清理,0.6–0.7用於物件替換並匹配風格,0.8–1.0用於完整區域替換。 - 在提示中說明遮罩外要保留的內容:
"preserve rooflines and sky gradient"、"match brick pattern and mortar tone"。 - 即使遮罩已定義區域,空間標籤仍有幫助:
"the left shelf"、"upper-right quadrant"。
限制
- 每個路由繼承其模型的限制。 Nano Banana:1–20 張輸入,1–4 張輸出。GPT Image 2 Edit:最多 10 個參考,4 種固定尺寸。Flux Kontext:單張參考。Z-Image Inpaint:需遮罩。
- 無多路由混合。 此技能每次呼叫只選一個模型。
- 品牌特定覆寫——如果使用者指定了特定模型,請路由至對應的品牌技能(
gpt-image-edit、flux-kontext、nano-banana-edit)以獲得更完整的處理。
退出碼
| 代碼 | 意義 |
|---|---|
| 0 | 成功 |
| 64 | CLI 參數錯誤 |
| 65 | 輸入 JSON 錯誤 / 結構不符 |
| 69 | 上游 5xx 錯誤 |
| 75 | 可重試:逾時 / 429 |
| 77 | 未登入或 Token 被拒絕 |
完整參考:docs.runcomfy.com/cli/troubleshooting。
運作方式
此技能根據使用者意圖選取 Nano Banana Edit / GPT Image 2 Edit / Flux Kontext Pro / Z-Image Turbo Inpaint 其中之一,並以對應的 JSON 主體執行 runcomfy run <model_id>。CLI 會向 Model API 發送 POST 請求、輪詢請求狀態、取得結果,並將任何 .runcomfy.net/.runcomfy.com URL 下載至 --output-dir。按下 Ctrl-C 會在結束前取消遠端請求。
安全性與隱私
- Token 儲存:
runcomfy login會將 API token 寫入~/.config/runcomfy/token.json,權限設為 0600(僅擁有者可讀寫)。在 CI/容器中可設定RUNCOMFY_TOKEN環境變數以繞過檔案。 - 輸入邊界:使用者提示詞以 JSON 字串形式透過
--input傳遞給 CLI。CLI 不會對提示詞進行 shell 展開;它會直接將 JSON 主體透過 HTTPS 傳送給 Model API。提示詞內容不會造成 shell 注入風險。 - 第三方內容:您傳遞的圖片/遮罩/影片 URL 是由 RunComfy 模型伺服器擷取,而非您機器上的 CLI。請將外部 URL 視為不可信任;基於圖片的提示注入是任何圖片/影片編輯模型的已知風險。
- 對外端點:僅
model-api.runcomfy.net(請求提交)和*.runcomfy.net/*.runcomfy.com(生成輸出的下載白名單)。無遙測、無回呼。 - 生成檔案大小上限:CLI 會中止任何超過 2 GiB 的單一下載,以防止惡意或失控模型輸出導致磁碟填滿。





