mcpField
I
image-text-replace

image-text-replace

github.com/meituCreative & media36132 installsUpdated 9w ago
Repository

About image-text-replace

image-text-replace is a skill for replacing text in existing images through meitu-cli. It routes simple, short one-location edits separately from stylized, multi-location, or length-changing edits, with fallback across editing methods.

Key features

  1. 01Replace text in an existing image
  2. 02Route simple and complex edits
  3. 03Fallback across editing methods
  4. 04Save downloaded results to an output folder

Use cases

  1. 01Correct a short printed label in an image
  2. 02Replace stylized or handwritten lettering
  3. 03Change text in multiple image locations
  4. 04Save an edited image to the configured folder

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/meitu/meitu-skills --skill image-text-replace

After installing, type/image-text-replacein Claude Code to confirm it loaded.

Details

From the project README

Image Text Replace

Overview

对已有图片做文字内容替换:简单精准改字(标准印刷体/单处/≤6 字符/字符数不变四条件全满足)与复杂改字(花字/手写体/风格化/多处/字符数变化)。

API Mapping

  • 简单精准改字:简单改字路径。
  • 复杂改字:优先 praline_pro,失败依次降级为 praline_lite、mint_edit。

Dependencies

  • meitu-cli: >=2.0.6
  • 凭证:CONFIG AKSK → meitu tools update;EXEC AKSK → 实际执行(见根 CONFIG.md)
  • 环境变量:MEITU_OPENAPI_TOOL_TASK_MODE=command

路径别名:$VISUAL = {OPENCLAW_HOME}/workspace/visual/

Core Workflow

Preflight → Execute → Deliver
Preflight
  1. meitu --version ≥ 2.0.6
  2. 已用 CONFIG AKSK 跑过 meitu tools update
  3. 当前 AKSK = EXEC,MEITU_OPENAPI_TOOL_TASK_MODE=command
  4. output_dir:openclaw.yaml → ./output/ |else → $VISUAL/output/image-text-replace/;mkdir -p
Execute

触发信号 / 路由规则

核心维度:四条件判断(必须同时满足):

  1. 字体类型:标准印刷体(宋体/黑体/楷体/圆体/衬线体/无衬线体/等宽字体)
  2. 修改位置:只修改一处文字
  3. 字符长度:修改的文字字符数 ≤ 6
  4. 字符数恒等:原文字符数 = 修改后字符数
场景判定路由
四条件全满足标准印刷体 + 单处 + ≤6 字符 + 字符数不变简单改字路径 → praline_pro → praline_lite → mint_edit
花字 / 手写 / 风格化花体字、手写、风格化praline_pro → praline_lite → mint_edit
多处修改改多个地方praline_pro → praline_lite → mint_edit
字符数 >6 或 字符数变化长文本 / 3 字→5 字praline_pro → praline_lite → mint_edit

参数定义

参数类型必填说明
image_urlSTRING是图片地址。缺失 → 提示"请提供需要改字的图片"
source_wordsSTRING条件必填原文字内容。简单改字必填;复杂改字可从 prompt 自动提取
target_wordsSTRING条件必填目标文字内容。简单改字必填
promptSTRING否改字描述;复杂改字时根据 source_words / target_words 自动生成英文改字指令

简单改字路径直接传 image_url、source_words 和 target_words;复杂改字使用 praline_pro、praline_lite 或 mint_edit,并根据 source_words/target_words 构造英文改字指令。

目标文字含中文时,prompt 中目标文字保持原样、不做翻译。

工具调用

meitu image-text-replace --image_url <url> --source_words "<原文>" --target_words "<新文>" --json --download-dir {output_dir} --skill_name skill_image-text-replace

错误降级

场景处理方式
image_url 缺失提示"请提供需要改字的图片"
image_url 不可访问直接返回图片链接无效错误,不重试
source_words / target_words 缺失提示"请告诉我要把哪个文字改成什么"
source_words 在图片中找不到返回原图,告知未找到匹配文字
字符数改变 / 花字 / 多处不走简单改字,直接使用 praline_pro
简单改字路径调用失败自动升级至 praline_pro
praline_pro 调用失败自动降级至 praline_lite
praline_lite 调用失败自动降级至 mint_edit
mint_edit 调用失败返回错误
用户一次要改多张图提示每次处理一张
用户未提供字体信息按标准印刷体判断,先试简单 API;失败自动升级
内容合规拦截直接返回合规提示,不重试、不降级
Deliver
  • 使用 Preflight 解析的 output_dir
  • 从 downloaded_files[0].saved_path 读取已下载文件路径
  • mv {downloaded_files[0].saved_path} {output_dir}/{YYYY-MM-DD}_{descriptive}_image-text-replace.{ext}

Output

  • 格式:image
  • 位置:项目 → ./output/,一次性 → $VISUAL/output/image-text-replace/

基线 Task ID

见 references/task-id-baseline.md 中对应行。

Comments

Markdown supported