Image forge skill

From jiushiwon/wg-skills · View interactive version

Image forge skill is an AI agent skill from the GitHub repository jiushiwon/wg-skills. ⚠️ 已迁移到 frontend-icon-skill。图片处理与图标生成能力(压缩、转格式、改尺寸、裁剪、base64、水印、遮罩、多图合成、SVG→PNG)已整体并入 frontend-icon-skill,使用 image-forge.cjs。触发词:「处理图片」「压缩图片」「转 webp」「加水印」「图片合成」「生成图标」「做一套图标」「icon 生成」「生成 png 图标」

How to use this skill

Skill file

image-forge-skill — 图片处理 & 图标生成

⚠️ 已迁移:本技能已整体并入 frontend-icon-skill。

image-forge.js → frontend-icon-skill/image-forge.cjs(命令接口完全不变)。

基于 sharp 的配置驱动工具,内置可执行脚本 image-forge.js。两种配置模式:

脚本位置

脚本 image-forge.js 与本 SKILL.md 在同一目录。设该目录为 $SKILL_DIR(运行时即本技能所在目录的绝对路径,例如 ~/.claude/skills/image-forge-skill)。

首次使用前需在该目录装一次依赖(sharp):

cd "$SKILL_DIR" && npm install

调用方式

从技能目录运行,让 require('sharp') 能解析到本地依赖:

cd "$SKILL_DIR" && echo '<JSON>' | node image-forge.cjs -

或写入临时文件再传入:node image-forge.cjs /path/to/spec.json

① icons 模式 — 图标生成

用户只需说清「要哪些图标、什么颜色、放哪个目录」,由你写好 JSON 并运行。

{
  "outDir": "<目标项目>/src/static/icons/login",
  "size": 72,
  "color": "#059669",
  "strokeWidth": 2,
  "icons": [
    { "name": "feature-data.png", "path": "M9 12h6m-6 4h6..." },
    { "name": "custom.png", "svg": "<svg ...>...</svg>" }
  ]
}

工作流:确认三要素(输出目录、主题色、要哪些图标)→ 写 JSON → 运行脚本 → 回报 [OK] 路径。

常用 path 速查(heroicons outline,stroke 风格):

需要其它图标时,按 heroicons/feather 语义自行给出对应 path。

② jobs 模式 — 图片处理

适用于压缩、转格式、改尺寸、裁剪、base64、水印、遮罩、多图合成。

{
  "outDir": "./dist",
  "defaults": { "format": "webp", "quality": 85, "fit": "cover" },
  "jobs": [
    {
      "type": "image",
      "input": "src/photo.jpg",
      "output": "photo-thumb.webp",
      "format": "webp",
      "quality": 85,
      "resize": { "width": 800, "height": 600, "fit": "cover" },
      "base64": false,
      "overlays": []
    },
    {
      "type": "composite",
      "output": "banner.jpg",
      "width": 1200,
      "height": 600,
      "background": "#eeeeee",
      "backgroundOpacity": 1,
      "layers": [
        { "type": "image", "input": "src/bg.jpg", "fit": "cover", "width": 1200, "height": 600 },
        { "type": "color", "color": "#000000", "opacity": 0.3 },
        { "type": "text", "text": "标题", "x": 600, "y": 300, "fontSize": 72, "color": "#ffffff", "align": "center" }
      ]
    }
  ]
}

处理类型

| 类型 | 字段 | 说明 |

|------|------|------|

| 单图处理 | format, quality, resize.*, base64 | 压缩、转格式、裁剪 |

| 图片水印 | overlays[].type: image | 图片叠加层 |

| 文字水印 | overlays[].type: text | 文字叠加层 |

| 纯色遮罩 | overlays[].type: color | 颜色遮罩层 |

| 多图合成 | type: composite | 画布 + 多图层 |

详细字段说明见 references/operation-schema.md。

image 任务

composite 任务

执行边界

以下场景超出本技能范围,应拒绝并建议换工具:

异常处理

与其他技能的关系

| 技能 | 关系 |

|------|------|

| icon-image-catch-skill | 远程抓图 → 本技能处理 |

| uniapp-theme-skill | 主题换肤后,用本技能 icons 模式生成主题色 tabBar 图标 |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.