yueban-image-to-code 是一个用于 Codex 的图片转代码与切图 skill,目标是把选中的 UI 图片或设计截图按 750px 画板宽度进行像素级还原,并导出独立透明 PNG 切图资源。 调用名:.
$ npx -y skills add SemineChen/yueban-image-to-code --agent claude-code
yueban-image-to-code 是一个用于 Codex 的图片转代码与切图 skill,目标是把选中的 UI 图片或设计截图按 750px 画板宽度进行像素级还原,并导出独立透明 PNG 切图资源。
调用名:
$yueban-image-to-code
750px读取当前源图,记录原始尺寸。
计算缩放比例:
scale = 750 / source_width
final_width = 750
final_height = round(source_height * scale)
创建 layers.manifest.json,记录每个图层的原图 bbox、缩放后 bbox、类型、z-index 和资源路径。
使用 bbox 预览脚本检查切图区域是否准确。
按 manifest 从源图导出透明 PNG 切图。
使用 manifest 坐标实现 750px 固定画板代码。
分别验收矢量层、文本层、位图/图标切图层。
截图并与 750px 原图叠图复核。
yueban-image-to-code/
├── SKILL.md
├── README.md
├── agents/
│ └── openai.yaml
├── references/
│ └── slicing.md
└── scripts/
├── audit_png_assets.py
├── compare_images.py
├── extract_png_asset.py
└── preview_bboxes.py
layers.manifest.json 示例:
[
{
"id": "avatar",
"type": "bitmap",
"source_bbox": { "x": 86, "y": 112, "width": 120, "height": 120 },
"scaled_bbox": { "x": 86, "y": 112, "width": 120, "height": 120 },
"z_index": 10,
"asset": "assets/images/avatar.png",
"transparent_required": true
},
{
"id": "username",
"type": "text",
"text": "橘子果酱",
"source_bbox": { "x": 252, "y": 134, "width": 140, "height": 40 },
"scaled_bbox": { "x": 252, "y": 134, "width": 140, "height": 40 },
"font_size": 32,
"font_weight": 700,
"color": "#07162A",
"z_index": 20
}
]
在源图上画出 manifest 中记录的 bbox,用于检查切图区域是否准确。
scripts/preview_bboxes.py source.png layers.manifest.json qa/bbox-preview.png --only-type bitmap
从源图按精确 bbox 导出 PNG。脚本不会自动 trim,输出画布固定等于 bbox。
scripts/extract_png_asset.py source.png assets/icons/icon-user.png \
--x 120 --y 980 --width 72 --height 72 \
--remove-bg floodfill \
--manifest layers.manifest.json \
--id icon-user
检查 PNG 是否贴边、尺寸是否匹配,以及透明背景是否合格。
scripts/audit_png_assets.py assets/icons assets/images \
--require-transparent-bg \
--manifest layers.manifest.json
对比 750px 原图和最终渲染截图。
scripts/compare_images.py reference-750.png render-750.png --json
750px将整个目录放到 Codex 的 skills 目录:
~/.codex/skills/yueban-image-to-code
然后在 Codex 中使用:
使用 $yueban-image-to-code 将当前选中的 UI 图片转换为代码,并导出透明 PNG 切图资源。
yueban-image-to-code is a Claude Code plugin with 1 hand-picked skill, indexed on Flowy in the Code Generation category. Install it with the command on its page. It includes yueban-image-to-code. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.
Is this plugin yours?
Claim it with GitHubSubmit a pluginPromote it