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`。触发词包括“图像编辑”、“编辑图像”、“图像到图像”、“i2i”、“替换背景”、“移除对象”、“重写标题”或任何明确要求编辑单张或批量图像的请求。

20Star
9Fork
更新于 2026/6/14
SKILL.md
readonly只读
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 多语言排版领域同类最佳
多参考合成(主体来自 img1,场景来自 img2,调色板来自 img3) 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 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": "保持主体身份、姿势和服装不变。将背景转换为雨夜霓虹赛博朋克街道。",
    "image_urls": ["https://.../portrait.jpg"]
  }' \
  --output-dir <absolute/path>

批量(锁定宽高比 + 分辨率):

runcomfy run google/nano-banana-2/edit \
  --input '{
    "prompt": "将右下角的水印替换为干净的白色无衬线字体文本 \"AURA\"。保持其他所有内容与输入完全一致。",
    "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 URL。第一个是主要图像;其余是辅助图像。
size enum auto auto1024_10241024_15361536_1024仅限这些。

调用

多语言文本重写:

runcomfy run openai/gpt-image-2/edit \
  --input '{
    "prompt": "保持照片、布局和品牌标志与输入完全一致。仅替换图像内的标题。新标题为粗体日文假名 \"今日のおすすめ\",位置和字体粗细相同。",
    "images": ["https://.../poster-en.jpg"]
  }' \
  --output-dir <absolute/path>

多参考合成:

runcomfy run openai/gpt-image-2/edit \
  --input '{
    "prompt": "将图像 1 的主体合成到图像 2 的房间中。匹配图像 2 的光照和色调。保持图像 1 主体身份不变。",
    "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 从支持的宽高比中选择。
seed int 可复现性。

仅单张图像——无数组。对于多图像流程,请使用路由 1(Nano Banana Edit)。

调用

runcomfy run blackforestlabs/flux-1-kontext/pro/edit \
  --input '{
    "prompt": "保持人物的面部、姿势和服装不变。在她左手中添加一把橙色雨伞,并带有一丝微笑。",
    "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 输出宽高比。
seed int 可复现性。

调用

对象移除(低强度):

runcomfy run tongyi-mai/z-image/turbo/inpainting \
  --input '{
    "prompt": "移除头顶电缆;保持屋顶轮廓和天空渐变;填充干净的天空。",
    "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": "将杂乱的背景替换为平滑的浅灰色摄影背景纸;仅掩码背景。",
    "image": "https://.../product.jpg",
    "mask_image": "https://.../bg-mask.png",
    "strength": 0.9
  }' \
  --output-dir <absolute/path>

提示技巧

  • 需要掩码 URL——灰度,白色 = 修复区域,黑色 = 保持。掩码边缘轻微模糊(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 未登录或令牌被拒绝

完整参考: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 向模型 API 发送 POST 请求,轮询请求,获取结果,并将任何 .runcomfy.net/.runcomfy.com URL 下载到 --output-dirCtrl-C 在退出前取消远程请求。

安全与隐私

  • 令牌存储runcomfy login 将 API 令牌写入 ~/.config/runcomfy/token.json,权限为 0600(仅所有者读写)。在 CI/容器中设置 RUNCOMFY_TOKEN 环境变量以完全绕过文件。
  • 输入边界:用户提示通过 --input 作为 JSON 字符串传递给 CLI。CLI 不会对提示进行 shell 扩展;它直接将 JSON 主体通过 HTTPS 传输到模型 API。提示内容不存在 shell 注入风险。
  • 第三方内容:您传递的图像/掩码/视频 URL 由 RunComfy 模型服务器获取,而非您机器上的 CLI。将外部 URL 视为不可信;基于图像的提示注入是任何图像编辑/视频编辑模型的已知风险。
  • 出站端点:仅 model-api.runcomfy.net(请求提交)和 *.runcomfy.net/*.runcomfy.com(生成输出的下载白名单)。无遥测,无回调。
  • 生成文件大小上限:CLI 会中止任何超过 2 GiB 的单个下载,以防止恶意或失控模型输出导致磁盘填满。