Files
agent/skills/image-process/SKILL.md
T
kicer a52b227d8b refactor(skills): 本地安装改成「README 式说明」,install.sh/requirements.txt 归服务器
按三条原则收紧:
1) 线上零影响:office/install.sh 回退成原来的 linux-only 版本(本地本来就不该跑它);
   image-process 的字体候选表撤回(那是在代码里写环境兼容,方向错了)。
2) install.sh / requirements.txt 只做服务器工件:镜像构建与 agent-executor-init 读它们,
   行为一字未变。
3) 本机缺东西时由 .md 指路,模型自己去装:四个技能各加 INSTALL.md(具体命令 + 平台
   资产/字体表 + 验证方式),并在 SKILL.md 里各加一行指向它(skill get 就能看到)。
   报错文案带上 INSTALL.md 的绝对路径,所以「撞到缺依赖」的那一刻就能拿到说明书。

保留的两处代码钩子都不是环境探测,而是「说明书里写的安装方式得真能生效」:
- office: start.sh 把 skills/office/scripts 塞进 PATH(本地没 root 写 /usr/local/bin);
  封装层 ENOENT 指向 INSTALL.md。
- x2pdf: find_soffice() 探 macOS app bundle(brew cask 装的 soffice 不在 PATH);
  WeasyPrint 不可用时回落 LibreOffice,让本地只需一个后端而不是 pango+WeasyPrint 两条链。

INSTALL.md 里 officecli 指向 releases/latest(它会自更新,实测 1.0.157 跑一次变 1.0.160),
不要求与服务器 pin 对齐。

实测:office --version / office create / office view outline 正常;x2pdf 缺 markdown 与
image-process 缺字体两条报错都给出 INSTALL.md 绝对路径,按 font 参数即通过。
2026-11-11 17:34:30 +08:00

111 lines
5.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: image-process
description: 普通图片/截图的确定性编辑(Pillow):查看信息、转格式、缩放、裁剪、压缩、加水印、九宫格切片、多图拼图
input_schema:
type: object
properties:
action:
type: string
description: 操作类型:info | convert | resize | crop | compress | watermark | slice | grid
input:
type: string
description: 输入图片路径(grid 时为图片所在目录)
output:
type: string
description: 输出文件路径(可选;slice 时为输出目录,grid 时也可省略)
width:
type: integer
description: resize 目标宽 / crop 裁切宽
height:
type: integer
description: resize 目标高 / crop 裁切高
keep_ratio:
type: boolean
description: resize 是否保持宽高比(默认 true;false 时需同时给 width 与 height)
left:
type: integer
description: crop 起始横坐标(默认 0)
top:
type: integer
description: crop 起始纵坐标(默认 0)
quality:
type: integer
description: JPEG/WebP 输出质量 1-95(默认 85)
max_dim:
type: integer
description: compress 可选:长边先缩到该值以内再压缩
text:
type: string
description: watermark 水印文字
font:
type: string
description: watermark 字体 TTF/TTC 路径(可选;中文缺省自动找系统文泉驿/Noto 字体)
font_size:
type: integer
description: watermark 字号(默认取图片宽的 1/20)
position:
type: string
description: watermark 位置 tl/tc/tr/ml/mc/mr/bl/bc/br(默认 br 右下)
color:
type: string
description: watermark 颜色 white/black/red 等或 #RRGGBB(默认 white)
opacity:
type: integer
description: watermark 不透明度 0-255(默认 200)
margin:
type: integer
description: watermark 距边缘像素(默认 20)
rows:
type: integer
description: slice 行数(默认 3;只给 rows 或 cols 时按方形推算)
cols:
type: integer
description: slice 列数(默认 3)
cell:
type: integer
description: grid 每格缩略图长边像素(默认 800)
padding:
type: integer
description: grid 格间距与外边距像素(默认 10)
background:
type: string
description: grid 背景色 white/black 等或 #RRGGBB(默认 white)
required: [action, input]
output_schema:
type: string
description: 操作结果描述;需要保存的动作会返回输出文件路径(slice 返回全部切片文件清单)
---
## 功能
- `info`:查看图片尺寸、色彩模式、格式、文件大小(需要裁剪/拼图前先看尺寸时很有用)
- `convert`:格式转换(按 `output` 的扩展名输出,支持 jpg/jpeg/png/webp/bmp/gif/tiff)
- `resize`:缩放,默认保持宽高比(fit);`keep_ratio=false` 时为精确宽高
- `crop`:按 `left/top/width/height` 裁剪,默认从 (0,0) 裁到右下角
- `compress`:压缩图片体积(`quality`;可选 `max_dim` 先缩长边);PNG 用 optimize 无损优化
- `watermark`:给图片加文字水印(支持中文;默认右下、白色、80% 不透明度)
- `slice`:等分切片(默认 3×3 九宫格),输出到独立目录,方便朋友圈/小红书九图
- `grid`:把同一目录下多张图拼成一张 contact sheet(缩略图网格)
## 使用说明
通过 `skill` 的 `{"op":"run","name":"image-process","args":{...}}` 调用,参数:
- `action`:操作类型(必填)
- `input`:输入图片或目录(必填;相对会话工作目录的路径即可,会自动转绝对路径)
- `output`:输出路径(建议给全;不给时自动生成 `<原名>_<动作>.<原扩展名>`,绝不覆盖原图)
- 其余参数见上方 schema,按动作选用
示例:
```json
{"action": "resize", "input": "photo.jpg", "width": 800, "output": "photo_800.jpg"}
{"action": "compress", "input": "big.png", "quality": 80}
{"action": "watermark", "input": "pic.png", "text": "内部资料", "position": "tr", "color": "white", "opacity": 180}
{"action": "grid", "input": ".", "output": "contact.jpg", "cols": 3}
{"action": "slice", "input": "nine.png", "rows": 3, "cols": 3, "output": "nine_slice"}
```
## 注意事项
- 本技能**只做确定性图像处理**(转换/缩放/裁剪/压缩/水印/拼图),不含 AI 生成、抠图、换脸、扩图、修复等生成式/语义编辑能力。
- 若用户的需求属于"文生图 / AI 修图"等生成式范畴,不要用本技能硬凑,应说明能力边界并推荐第三方工具(豆包、即梦、可灵、Photoshop 等)。
- 任何操作都不会覆盖输入原图;输出目录不存在时自动创建。
- 中文水印需要字体:优先用 `font` 参数指定;否则依赖系统字体(镜像预装文泉驿)。
- 输入依赖 Pillow;本机缺 Pillow 或字体时按同目录 `INSTALL.md` 自己装(服务器由镜像 + `requirements.txt` 提供)。