本文へ移動
cccskills
無料GitHub で公開

daftai-image-to-svg

Converts transparent or solid-background single-color PNG files and SVG files containing one embedded or local PNG into verified path-only SVG output. Removes pure-color backgrounds automatically. Uses Potrace threshold and parameter scans with alpha error metrics to preserve detailed logos, stamps, engravings, and line art. Use when the user asks to convert images to SVG, vectorize PNG, convert bitmap to true SVG, remove embedded raster data from SVG, 图片转矢量, PNG 转 SVG, 真矢量, or 位图描摹.

インストール方法を見る

含まれるファイル(6)

  • SKILL.md6.6 KB
  • agents/openai.yaml284 B
  • CLAUDE.md1017 B
  • scripts/background.ts3.9 KB
  • scripts/vectorize.test.ts9.7 KB
  • scripts/vectorize.ts20.3 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Image to SVG

Convert transparent or solid-background single-color artwork into a genuine SVG containing paths rather than an embedded bitmap.

Automatic tracing approximates the raster boundary. Only the original vector source can provide mathematically exact curves.

Scope

Supported:

  • Transparent PNG.
  • PNG on a pure-color background, including white, red, green, or other flat colors.
  • SVG containing exactly one Base64 or local PNG.
  • Single-color logos, stamps, engravings, silhouettes, and detailed line art.

Reject:

  • Photos, gradients, textured backgrounds, and multicolor artwork.
  • Remote image URLs.
  • SVG mixing raster artwork with existing paths.
  • Centerline or editable-stroke reconstruction.

For multicolor artwork, recommend VTracer instead of forcing this workflow.

Script Directory

Important: All scripts are located in the scripts/ subdirectory of this skill.

Agent Execution Instructions:

  1. Determine this SKILL.md file's directory path as SKILL_DIR.
  2. Set command working directory to ${SKILL_DIR}.
  3. Execute bun ${SKILL_DIR}/scripts/vectorize.ts.
  4. Replace ${SKILL_DIR} with the absolute path.
ScriptPurpose
scripts/vectorize.tsExtract alpha, scan Potrace candidates, measure error, and deliver the best path-only SVG
scripts/vectorize.test.tsUnit and real-toolchain regression tests

Dependencies

Detect the runtime once per session:

command -v bun
command -v ffmpeg
command -v ffprobe
command -v potrace
command -v rsvg-convert || command -v inkscape

Required:

  • Bun.
  • FFmpeg and FFprobe.
  • Potrace.
  • One SVG renderer: rsvg-convert from librsvg, or Inkscape.

If a dependency is missing, install it directly with the available package manager. Report only when installation fails or no package manager is available.

Common macOS installation:

brew install oven-sh/bun/bun
brew install ffmpeg potrace librsvg

If Homebrew is unavailable, install with the platform package manager. Do not ask before installing missing conversion dependencies.

Workflow

  1. Confirm the input is within scope.

  2. Run the converter:

    bun ${SKILL_DIR}/scripts/vectorize.ts "/absolute/path/to/input.svg"
    
  3. Read <source-slug>.report.json.

  4. Confirm:

    • structure.pathCount >= 1;
    • structure.imageCount === 0;
    • structure.dataImageCount === 0;
    • verified4x === true.
    • backgroundRemoval.applied === true only when the input had a solid background.
  5. Inspect the PNG preview, especially fine lines, holes, hatching, and sharp corners.

  6. Report the SVG, preview, selected threshold, MAE, RMSE, and IoU.

Choose the objective explicitly:

  • Use default mae for the closest alpha appearance.
  • Use iou for overlap, contour match, 轮廓重合率, or IoU requests.
  • Use rmse only when large alpha errors matter more than average error.

Never describe the result as lossless. Say “high-fidelity true vector” and include measured error.

Usage

Specify an output parent directory:

bun ${SKILL_DIR}/scripts/vectorize.ts input.png --output-dir ./output

Override the detected color:

bun ${SKILL_DIR}/scripts/vectorize.ts input.svg --color "#0113a8"

Use solid-background PNG directly; do not preprocess manually:

bun ${SKILL_DIR}/scripts/vectorize.ts "logo-on-white.png"

Preserve all threshold candidates for manual comparison:

bun ${SKILL_DIR}/scripts/vectorize.ts input.svg --keep-candidates

Temporary candidates are deleted by default. Keep them only when tuning, comparing versions, or resolving visual review disputes.

Advanced threshold control:

bun ${SKILL_DIR}/scripts/vectorize.ts input.svg \
  --threshold-min 120 \
  --threshold-max 140 \
  --threshold-step 2

Validated defaults are 124..144, step 2, Potrace alphamax=0.2, and optimization tolerance 0.03.

Optimize for binary outline overlap and scan Potrace smoothing:

bun ${SKILL_DIR}/scripts/vectorize.ts input.svg \
  --objective iou \
  --threshold-min 122 \
  --threshold-max 132 \
  --threshold-step 1 \
  --alphamax 0,0.2 \
  --opttolerance 0,0.03

For detailed hard-edge art, alphamax=0 can raise IoU by avoiding curve smoothing. Do not hard-code color during experiments; inherit wrapper fill or use --color.

Output

Single-file runs write directly into the chosen output directory:

<output-dir>/
├── <source-slug>.svg
├── <source-slug>.preview.png
└── <source-slug>.report.json

Default runs do not create candidates/. With --keep-candidates, also write all measured candidates:

<output-dir>/
├── <source-slug>.svg
├── <source-slug>.preview.png
├── <source-slug>.report.json
└── candidates/
    ├── candidate-t128-a0-o0.svg
    ├── candidate-t128-a0-o0.png
    └── ...

If --output-dir is omitted, create <source-slug>-svg-output/ next to the input. Existing results are never overwritten; repeated runs append a timestamp to the output filename prefix. Do not copy the source file by default; the report records sourcePath.

For multiple input files, create one subdirectory per source under the chosen output parent to avoid collisions:

<output-parent>/
├── first-image/
│   ├── first-image.svg
│   ├── first-image.preview.png
│   └── first-image.report.json
└── second-image/
    ├── second-image.svg
    ├── second-image.preview.png
    └── second-image.report.json

The report records backgroundRemoval when a pure-color background was converted to alpha. Intermediate PGM files remain temporary; candidate SVG/PNG files are preserved only with --keep-candidates.

Validation

Run:

bun test ${SKILL_DIR}/scripts/vectorize.test.ts

For final delivery, also validate the generated SVG:

xmllint --noout "/path/to/result.svg"
rg -o '<path\b|<image\b|data:image/' "/path/to/result.svg" | sort | uniq -c

The final SVG must contain paths and no raster references.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Checks and fixes Chinese copywriting with autocorrect-backed workflows for text and single-file Markdown/TXT inputs. Use when user asks to normalize Chinese punctuation, spacing, full-width/half-width usage, or copywriting style. Also triggers for "校对", "检查排版", "中英文空格", "全角半角".

日本語の概要は準備中です。原文の説明を表示しています。

daftAI2026/daftAI-skills182026年9月10日 更新

Extracts timed subtitles from local video/audio files using Whisper. Outputs SRT format with accurate timestamps. Handles complex filenames automatically. Use when user asks to "extract subtitles", "get subtitles", "transcribe video", "识别字幕", "提取字幕", or "获取字幕".

日本語の概要は準備中です。原文の説明を表示しています。

daftAI2026/daftAI-skills182026年9月10日 更新

Optimizes natural-language image requests and rough prompts into ready-to-use GPT Image 2.5 prompts using the official prompting guide as a live reference. Use when users ask to improve image prompts, 优化生图提示词, 把想法变成提示词, or write prompts for GPT Image 2.5 Flare or Sunburst. Produces prompt text, not images, unless the user explicitly asks to generate.

日本語の概要は準備中です。原文の説明を表示しています。

daftAI2026/daftAI-skills182026年9月10日 更新

Translate subtitle files (SRT/VTT) between languages. Auto-detect source language, batch translate with count validation, optional bilingual merge output. Use when user asks to "translate subtitles", "翻译字幕", "subtitle translation", or needs subtitles converted to another language.

日本語の概要は準備中です。原文の説明を表示しています。

daftAI2026/daftAI-skills182026年9月10日 更新

Fetch any URL and convert to markdown using Chrome CDP, with automatic image downloading. Supports auto-capture and wait-for-user modes. Downloads article images to local directory and rewrites image references to relative paths. Use when user wants to save a webpage as markdown with images. Keywords: url to markdown, save webpage, download article, 网页转markdown

日本語の概要は準備中です。原文の説明を表示しています。

daftAI2026/daftAI-skills182026年9月10日 更新

Burn subtitles into local video files. Supports SRT/VTT/ASS formats, auto-detect subtitles and language, bilingual subtitle merging and translation. Use when user needs to hardcode subtitles into video. Keywords: 字幕烧录、burn subtitles、本地视频、hardcode subtitles

日本語の概要は準備中です。原文の説明を表示しています。

daftAI2026/daftAI-skills182026年9月10日 更新

daftAI2026 のスキルをすべて見る

このスキルの問題を報告する