image-edit

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」,或任何明確要求編輯單張或批次圖片的指令。

2星標
2分支
更新於 2026/6/18
SKILL.md
readonlyread-only
name
image-edit
description

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 最靈活,同時支援單張與批次

代理程式會讀取此表格,分類使用者意圖,並選取下方對應的小節。

前置需求

  1. RunComfy CLInpm i -g @runcomfy/cli
  2. RunComfy 帳號runcomfy login
  3. CI / 容器環境 — 設定 RUNCOMFY_TOKEN=<token>

路由 1:Nano Banana Edit — 一般編輯與批次處理的預設模型

模型google/nano-banana-2/edit

結構定義

欄位 型別 必填 預設值 備註
prompt string 先說明保留目標,再說明要做的變更。
image_urls array 1–20 個可公開存取的 HTTPS 網址。
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_ratioresolution
  • 小步疊代:將複合編輯拆成多個較短的步驟。

路由 2:GPT Image 2 Edit — 多語言文字 + 多參考圖合成

模型openai/gpt-image-2/edit

結構定義

欄位 型別 必填 預設值 備註
prompt string 編輯指令;先說明保留內容。
images string[] 最多 10 個 HTTPS 網址。第一個為主圖;其餘為輔助圖。
size enum auto auto1024_10241024_15361536_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 單張來源圖片網址。
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 來源圖片網址。
mask_image string 灰階遮罩網址(白色 = 要修補的區域,黑色 = 保留)。
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>

提示詞撰寫技巧

  • 遮罩網址為必填 — 灰階,白色 = 修補區域,黑色 = 保留。遮罩邊緣稍微模糊(1–3 像素)比銳利二值化邊緣效果更好。
  • 依意圖調整強度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-editflux-kontextnano-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 會將請求 POST 到 Model API、輪詢請求狀態、取得結果,並將任何 .runcomfy.net/.runcomfy.com 網址下載到 --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 注入風險。
  • 第三方內容:你傳遞的圖片/遮罩/影片網址是由 RunComfy 模型伺服器擷取,而非你本機的 CLI。請將外部網址視為不受信任的來源;基於圖片的提示詞注入是任何圖片編輯/影片編輯模型已知的風險。
  • 對外端點:僅有 model-api.runcomfy.net(請求提交)和 *.runcomfy.net / *.runcomfy.com(生成輸出的下載白名單)。無遙測、無回呼。
  • 生成檔案大小上限:CLI 會中止任何超過 2 GiB 的單一下載,以防止惡意或失控的模型輸出導致磁碟空間耗盡。