Claude Skill

lov-png2svg

Convert PNG images to high-quality SVG with optional white-background removal, vtracer spline vectorization, and svgo compression. Use when the user asks for "PNG to SVG", "png2svg", "转 SVG", "矢量化", "去白底", logo tracing, or converting raster icons into editable vector assets.

LLM Mart · 0 points · 7 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download lovstudio-skills-skills_png2svg-77d464c.zip · 4 KB
Part of lovstudio/skills — 83 skills

Install

skills CLI npx skills add https://github.com/lovstudio/skills/tree/main/skills/png2svg
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lovstudio-skills@llmmart
Git git clone https://github.com/lovstudio/skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole lovstudio/skills collection as a plugin from our marketplace. Git is the plain clone.

README

矢量描摹 · Vector Tracer

Version

Convert PNG images into high-quality SVG files with optional white-background removal, vtracer spline vectorization, and svgo compression.

Part of skill-publisher general skills — by example.com

Install

npx skills add png2svg -g -y

Dependencies

brew install imagemagick
cargo install vtracer
npm install -g svgo

npx svgo also works when svgo is not installed globally.

Workflow

magick input.png -fuzz 15% -transparent white -channel A -threshold 50% +channel input.temp.png
vtracer --input input.temp.png --output output.svg --mode spline --filter_speckle 8 --color_precision 8 --corner_threshold 120 --segment_length 6 --path_precision 5
npx svgo output.svg -o output.svg --multipass
rm -f input.temp.png

Options

Variable Default Description
INPUT_PNG required Source PNG path
OUTPUT_SVG input basename with .svg Target SVG path
KEEP_BG false Keep the original background instead of removing white

License

MIT

Skill manifest

矢量描摹 · Vector Tracer

将 PNG 图片转换为高质量矢量 SVG,支持去除白色背景。

工具链

PNG → magick (去白底+alpha阈值) → vtracer (样条曲线) → svgo (压缩) → SVG
  • ImageMagick (magick): 去除白色背景 + alpha 阈值处理
  • vtracer: 样条曲线矢量化(比 potrace 更平滑)
  • svgo: SVG 路径压缩优化

调用方式

当需要将 PNG 转换为 SVG 时,按以下步骤执行:

输入

  • INPUT_PNG: 输入 PNG 文件路径(必需)
  • OUTPUT_SVG: 输出 SVG 路径(默认:同名 .svg)
  • KEEP_BG: 是否保留背景(默认:false,去除白色背景)

执行步骤

Step 1: 预处理(去白底)

如果需要去除背景(KEEP_BG=false):

magick INPUT_PNG \
  -fuzz 15% -transparent white \
  -channel A -threshold 50% +channel \
  INPUT_PNG.temp.png

Step 2: 矢量化

vtracer --input INPUT_PNG.temp.png --output OUTPUT_SVG \
  --mode spline \
  --filter_speckle 8 \
  --color_precision 8 \
  --corner_threshold 120 \
  --segment_length 6 \
  --path_precision 5

Step 3: 压缩优化

npx svgo OUTPUT_SVG -o OUTPUT_SVG --multipass

Step 4: 清理

rm -f INPUT_PNG.temp.png

输出

返回生成的 SVG 文件路径,并报告文件大小。

✓ PNG → SVG 转换完成

输入: {INPUT_PNG}
输出: {OUTPUT_SVG}
大小: {file_size}

依赖

首次使用前确保已安装:

brew install imagemagick
cargo install vtracer
npm install -g svgo  # 或使用 npx

参数调优

参数 作用 调大效果
filter_speckle 过滤小斑点 更干净
corner_threshold 角点阈值 更平滑
segment_length 线段长度 更平滑
color_precision 颜色精度 更准确

Runtime context (shared)

运行前读取本 Skill 包的 skill.yaml,由宿主提供 skill-runtime/v1 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。

  • 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
  • required: true 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。
  • 报错提供可复制的 context_id、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。

通用反馈闭环

用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:

  1. 先判断意见是 task-specific(仅本次)还是 reusable(可跨任务复用)。
  2. task-specific 只修改当前任务,不改 Skill。
  3. reusable 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。
  4. 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。
  5. reusable 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。
Files (skills)
  • CHANGELOG.md 524 B
    # Changelog for png2svg
    
    ## [1.1.0] - 2026-08-24
    
    ### Added
    
    - add the shared feedback-classification and approval-invalidation gate used by every LovStudio Skill
    
    ## [1.0.1] - 2026-05-07
    
    ### Fixed
    
    - standardize Agent Skills metadata and README
    - expand trigger description and install documentation
    
    ## v1.0.0 - 2024-12-24
    - Initial release
    - 工具链: ImageMagick + vtracer + svgo
    - 支持去除白色背景(默认开启)
    - 支持 --keep-bg 保留背景
    - 支持自定义输出路径
    
    Author: 公众号:品牌方
    
  • README.md 1.2 KB
    # 矢量描摹 · Vector Tracer
    
    ![Version](https://img.shields.io/badge/version-1.1.0-CC785C)
    
    Convert PNG images into high-quality SVG files with optional white-background removal, vtracer spline vectorization, and svgo compression.
    
    Part of [skill-publisher general skills](https://example.com/skills/general-skills) — by [example.com](https://example.com)
    
    ## Install
    
    ```bash
    npx skills add png2svg -g -y
    ```
    
    ## Dependencies
    
    ```bash
    brew install imagemagick
    cargo install vtracer
    npm install -g svgo
    ```
    
    `npx svgo` also works when `svgo` is not installed globally.
    
    ## Workflow
    
    ```bash
    magick input.png -fuzz 15% -transparent white -channel A -threshold 50% +channel input.temp.png
    vtracer --input input.temp.png --output output.svg --mode spline --filter_speckle 8 --color_precision 8 --corner_threshold 120 --segment_length 6 --path_precision 5
    npx svgo output.svg -o output.svg --multipass
    rm -f input.temp.png
    ```
    
    ## Options
    
    | Variable | Default | Description |
    |---|---|---|
    | `INPUT_PNG` | required | Source PNG path |
    | `OUTPUT_SVG` | input basename with `.svg` | Target SVG path |
    | `KEEP_BG` | `false` | Keep the original background instead of removing white |
    
    ## License
    
    MIT
    
  • SKILL.md 3.8 KB
    ---
    name: lov-png2svg
    category: Document Conversion
    tagline: "PNG → high-quality SVG conversion with background removal and spline curves."
    description: >
      Convert PNG images to high-quality SVG with optional white-background removal,
      vtracer spline vectorization, and svgo compression. Use when the user asks
      for "PNG to SVG", "png2svg", "转 SVG", "矢量化", "去白底", logo tracing,
      or converting raster icons into editable vector assets.
    license: MIT
    compatibility: >
      Requires ImageMagick `magick`, vtracer, and svgo (`npx svgo` is supported).
      Works on macOS/Linux where those CLIs are installed.
    metadata:
      author: contributors
      version: "1.1.0"
      tags: png svg vectorization imagemagick vtracer
    ---
    
    # 矢量描摹 · Vector Tracer
    
    将 PNG 图片转换为高质量矢量 SVG,支持去除白色背景。
    
    ## 工具链
    
    ```
    PNG → magick (去白底+alpha阈值) → vtracer (样条曲线) → svgo (压缩) → SVG
    ```
    
    - **ImageMagick** (`magick`): 去除白色背景 + alpha 阈值处理
    - **vtracer**: 样条曲线矢量化(比 potrace 更平滑)
    - **svgo**: SVG 路径压缩优化
    
    ## 调用方式
    
    当需要将 PNG 转换为 SVG 时,按以下步骤执行:
    
    ### 输入
    
    - `INPUT_PNG`: 输入 PNG 文件路径(必需)
    - `OUTPUT_SVG`: 输出 SVG 路径(默认:同名 .svg)
    - `KEEP_BG`: 是否保留背景(默认:false,去除白色背景)
    
    ### 执行步骤
    
    #### Step 1: 预处理(去白底)
    
    如果需要去除背景(KEEP_BG=false):
    
    ```bash
    magick INPUT_PNG \
      -fuzz 15% -transparent white \
      -channel A -threshold 50% +channel \
      INPUT_PNG.temp.png
    ```
    
    #### Step 2: 矢量化
    
    ```bash
    vtracer --input INPUT_PNG.temp.png --output OUTPUT_SVG \
      --mode spline \
      --filter_speckle 8 \
      --color_precision 8 \
      --corner_threshold 120 \
      --segment_length 6 \
      --path_precision 5
    ```
    
    #### Step 3: 压缩优化
    
    ```bash
    npx svgo OUTPUT_SVG -o OUTPUT_SVG --multipass
    ```
    
    #### Step 4: 清理
    
    ```bash
    rm -f INPUT_PNG.temp.png
    ```
    
    ### 输出
    
    返回生成的 SVG 文件路径,并报告文件大小。
    
    ```
    ✓ PNG → SVG 转换完成
    
    输入: {INPUT_PNG}
    输出: {OUTPUT_SVG}
    大小: {file_size}
    ```
    
    ## 依赖
    
    首次使用前确保已安装:
    
    ```bash
    brew install imagemagick
    cargo install vtracer
    npm install -g svgo  # 或使用 npx
    ```
    
    ## 参数调优
    
    | 参数 | 作用 | 调大效果 |
    |-----|------|---------|
    | `filter_speckle` | 过滤小斑点 | 更干净 |
    | `corner_threshold` | 角点阈值 | 更平滑 |
    | `segment_length` | 线段长度 | 更平滑 |
    | `color_precision` | 颜色精度 | 更准确 |
    
    ## Runtime context (shared)
    
    运行前读取本 Skill 包的 `skill.yaml`,由宿主提供 `skill-runtime/v1` 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
    
    - 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
    - `required: true` 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。
    - 报错提供可复制的 `context_id`、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。
    
    ## 通用反馈闭环
    
    用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:
    
    1. 先判断意见是 `task-specific`(仅本次)还是 `reusable`(可跨任务复用)。
    2. `task-specific` 只修改当前任务,不改 Skill。
    3. `reusable` 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。
    4. 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。
    5. `reusable` 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。
    
  • skill.yaml 828 B
    schema: skill-manifest/v1
    id: lov-png2svg
    version: "1.1.0"
    runtime: skill-runtime/v1
    context:
      profile:
        fields:
        - path: identity.name
          required: true
          question: 如果本次输出需要品牌身份,请提供品牌名称。
        - path: identity.logo
          required: false
          question: 如果需要使用品牌 Logo,请提供 Logo 地址或文件路径。
        - path: brand.tone
          required: false
          question: 如果已有品牌语气或审美关键词,请提供它们。
      preferences:
        namespace: lov_png2svg
        fields:
        - path: user.language
          required: false
          question: 希望使用哪种语言输出?
        - path: user.timezone
          required: false
          question: 需要使用哪个时区处理日期和时间?
      interaction:
        ask_missing: true
        max_questions: 1
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related