mcpField
G
gpt-image-edit

gpt-image-edit

github.com/doany-ai创意与媒体5274.1k 次安装23 周前更新
代码仓库

关于 gpt-image-edit

gpt-image-edit 是通过 RunComfy Model API 使用 OpenAI GPT Image 2 编辑图像的 skill,可在局部修改时保留图像细节,也支持改写图中文字和多图参考合成。

主要功能

  1. 01定向编辑图像
  2. 02保留身份与版式
  3. 03改写多语言图中文字
  4. 04最多使用 10 张参考图
  5. 05选择输出宽高比

适用场景

  1. 01本地化广告标题
  2. 02替换品牌文字或行动号召
  3. 03合成不同参考图中的主体与场景
  4. 04调整版面元素位置

MCP 相关

此 skill 通过 RunComfy CLI 向 RunComfy Model API 提交图像编辑请求;输入未说明 MCP 集成。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/doany-ai/skills --skill gpt-image-edit

安装后在 Claude Code 中输入/gpt-image-edit确认已加载。

详细介绍

GPT Image Edit — RunComfy 专业版

runcomfy.com · 编辑端点 · 文生图同系列模型 · GitHub

RunComfy Model API 上的 OpenAI GPT Image 2 — /edit 端点(ChatGPT Images 2.0 图生图)。它在同类模型中最擅长通过定向编辑保留身份特征,以及重写图像中任何文字体系(拉丁字母、假名、中日韩文字、西里尔字母、阿拉伯文)的嵌入文字。

npx skills add agentspace-so/runcomfy-skills --skill gpt-image-edit -g

何时选择此模型(而非同系列其他模型)

需求使用
编辑图像中的多语言/嵌入文字GPT Image Edit
在翻译标题的不同版本中保留身份特征GPT Image Edit
精准编辑布局(移动标题、更换 CTA 等)GPT Image Edit
最多使用 10 张参考图GPT Image Edit
一致地批量处理最多 20 张图像Nano Banana Edit
单次精确局部编辑,优先忠实还原来源Flux Kontext
使用 GPT Image 2 从零生成同系列 gpt-image-2 技能
批量生成身份特征稳定的 SKU 图集Nano Banana Edit

前提条件

  1. RunComfy CLI — npm i -g @runcomfy/cli
  2. RunComfy 账户 — runcomfy login 会打开浏览器设备代码登录流程。
  3. CI/容器 — 设置 RUNCOMFY_TOKEN=<token>,而不是运行 runcomfy login。

端点和输入架构

openai/gpt-image-2/edit
字段类型必填默认值说明
promptstring是—编辑指令。先说明要保留的内容,最后说明要做的改动。
imagesstring[]是—最多 10 个可公开获取的 HTTPS URL。第一个是主图,其余为辅助图。
sizeenum否autoauto(保留输入图像)、1024_1024(1:1)、1024_1536(2:3 纵向)、1536_1024(3:2 横向)。

size=auto 会保留输入图像的比例——除非编辑明确要求更改取景范围,否则强烈建议使用此设置。

调用方法

保留单张参考图的编辑:

runcomfy run openai/gpt-image-2/edit \
  --input '{
    "prompt": "Keep the person'\''s face, pose, and brand mark unchanged. Replace the background with a soft warm-grey studio sweep and a gentle floor shadow.",
    "images": ["https://.../portrait.jpg"]
  }' \
  --output-dir <absolute/path>

多语言文字改写(除标题外保留所有内容):

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 as before.",
    "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 (face, pose, clothing) unchanged.",
    "images": ["https://.../subject.jpg", "https://.../room.jpg"]
  }' \
  --output-dir <absolute/path>

提示词——实际有效的方法

先说明保留目标。 务必先写:"Keep [face / pose / clothing / brand / framing] unchanged.",然后说明要做的改动。模型会优先遵循开头的要求。

多语言文字——引用字符并注明文字体系。 "the headline reads \"コーヒー\" in bold Japanese kana"、"the label says \"АРОМА\" in Cyrillic, white on black"、"the right-margin caption reads \"تخفيض\" in Arabic right-to-left"。不要转述——直接引用。

空间编辑使用方向性描述。 具体的空间范围描述效果很好:"move the headline from top-right to bottom-center"、"remove the leftmost object only"、"replace the watermark in the bottom-right corner"。

多参考图编号。 传入多张 images 时,按编号引用它们:"subject from image 1, lighting from image 2, color palette from image 3"。模型能够正确分配提示信息。

使用 size: "auto" 保留输入比例。 只有编辑明确要求更改取景范围时才覆盖此设置(例如将 16:9 图像裁剪为 1:1)。

反模式:

  • 过长的复合编辑指令(“更改 A、B、C 和 D”)→ 每增加一个编辑目标,偏移风险都会增大。
  • 未说明保留目标 → 模型可能会微妙地改写面部、品牌或取景范围。
  • 转述而非引用图像中的文字 → 输出文字会有所不同。
  • 将 size 设为 3 个固定值和 auto 以外的值 → 422。

适用场景

使用场景GPT Image Edit 的优势
多语言广告本地化一个源素材 → 同一标题的多种语言版本
符合品牌规范的标题 / CTA 替换精确的布局控制 + 保留指令,让其余部分保持稳定
多参考图合成(主体取自一张图,场景取自另一张图)编号参考图可准确传递线索
精确调整布局位置能遵循方向性描述(“从右上角移至底部中央”)
编辑标牌时保留身份特征在针对性编辑中,面部 / 品牌保留能力同类最佳

示例提示词(经验证可生成优质结果)

替换背景并完整保留其他内容(页面示例):

Turn the background into a bright minimal white-to-soft-gray studio
sweep with gentle floor shadow; add a large headline in-image that
reads "OPEN STUDIO" in a bold clean sans-serif, high contrast, centered;
keep the main person or product, pose, and face identity unchanged

多语言版本:

Keep the photograph, layout, lighting, 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 as before.

多参考图合成:

Compose subject from image 1 into the kitchen from image 2.
Match the warm window light and color palette of image 2.
Keep subject identity (face, pose, clothing) from image 1 unchanged.

局限性

  • size:3 个固定值 + auto — 其他值都会返回 422 错误。
  • images:最多 10 张 — 第一张是主图,其余为辅助线索。
  • 较长的复合提示词容易偏离 — 必要时拆分为多个处理步骤。
  • 要在大量 SKU 图片中保持批次一致性,Nano Banana Edit(最多 20 张)更合适。
  • 人像写实度方面 — Nano Banana Pro 更胜一筹。

退出代码

code含义
0成功
64CLI 参数错误
65输入 JSON 错误 / 架构不匹配
69上游 5xx 错误
75可重试:超时 / 429
77未登录或令牌遭拒

完整参考:docs.runcomfy.com/cli/troubleshooting。

工作原理

该技能使用符合架构的 JSON 请求体调用 runcomfy run openai/gpt-image-2/edit。CLI 会向 https://model-api.runcomfy.net/v1/models/openai/gpt-image-2/edit 发送 POST 请求,轮询请求状态,获取结果,并将任何 .runcomfy.net/.runcomfy.com URL 下载到 --output-dir。按下 Ctrl-C 会在退出前取消远程请求。

安全与隐私

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

评论

支持 Markdown