npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@visant/logo-trace

v0.1.0

Published

Raster → SVG vectorization tuned for logos. Potrace under the hood, with Otsu auto-threshold (+ auto-invert for light-on-light art), logo/lettering/lineArt/stamp presets, and a sanitize + optimize pass that yields a clean, minified SVG string.

Downloads

79

Readme

@visant/logo-trace

Raster → SVG vectorization tuned for logos. Potrace under the hood, wrapped with the bits that make a logo trace cleanly:

  • Otsu auto-threshold — picks the black/white cutoff per image instead of a fixed 128.
  • Auto-invert — light-on-light art (e.g. a gray wordmark on white) is inverted automatically before tracing, then inverted-retried if the first pass comes back empty.
  • Calibrated presetslogo, lettering, lineArt, stamp.
  • Sanitize + optimize — output is run through DOMPurify and a numeric/editor-cruft minifier, so you get a small, safe SVG string.

It powers the Visant Labs PNG→SVG trace endpoint and the Studio 3D GLB export (image → traced SVG → extruded mesh).

Install

npm i @visant/logo-trace
# node-first peers (the server already has these):
npm i sharp jsdom dompurify

potrace is a direct dependency. sharp (Otsu grayscale + invert), jsdom and dompurify (the sanitize/optimize pass) are optional peer dependencies, imported lazily. Without sharp, threshold: 'auto' degrades to a fixed 128; the sanitize pass requires jsdom + dompurify.

Usage

import { trace } from '@visant/logo-trace';
import { readFile } from 'node:fs/promises';

const png = await readFile('logo.png');

// Named preset:
const svg = await trace(png, { preset: 'logo' });
// → '<svg ...><path d="..."/></svg>'

// Or explicit options (override any preset value):
const svg2 = await trace(png, {
  preset: 'lettering',
  threshold: 'auto',   // Otsu + auto-invert
  turdSize: 2,         // drop speckles < 2px²
  optTolerance: 0.2,   // curve smoothing
  alphaMax: 0.8,       // corner roundness
  color: '#111111',
});

trace is an alias of tracePipeline (trace → sanitize → optimize). Use traceImage if you want the raw potrace output without the cleanup pass.

Exports

| Entry | Purpose | | --- | --- | | . | everything below, flat | | ./presets | TRACE_PRESETS, resolveTraceOptions | | ./sanitize | parseBase64Image, sanitizeSvg, optimizeSvg, cleanSvg |

API

| Export | Signature | | --- | --- | | trace / tracePipeline | (buffer, opts?) => Promise<string> — full pipeline | | traceImage | (buffer, opts?) => Promise<string> — raw potrace SVG, no cleanup | | cleanSvgPipeline / cleanSvg | (rawSvg) => Promise<string> — sanitize + optimize an existing SVG | | parseBase64Image | (dataUri) => Buffer \| null — parse a data:image/...;base64,... URI | | TRACE_PRESETS | calibrated parameter sets per preset | | resolveTraceOptions | (opts) => TraceOptions — merge a preset under explicit options |

Presets

| Preset | turdSize | optTolerance | threshold | alphaMax | | --- | --- | --- | --- | --- | | logo | 3 | 0.3 | auto | 0.8 | | lettering | 1 | 0.15 | auto | 0.5 | | lineArt | 0 | 0.1 | 128 | 1.0 | | stamp | 5 | 0.5 | auto | 0.8 |

From a base64 data URI

import { parseBase64Image, trace } from '@visant/logo-trace';

const buffer = parseBase64Image(dataUri); // null on a non-image / prefix-less string
if (!buffer) throw new Error('Invalid base64 image format');
const svg = await trace(buffer, { preset: 'logo' });

License

MIT