@dudko.dev/vectorize-core
v0.7.1
Published
Raster → SVG tracing (Rust/WASM core with a typed TypeScript API). Works in browsers and Node.
Maintainers
Readme
@dudko.dev/vectorize-core
Raster → vector conversion. A Rust tracing core compiled to WebAssembly, with a typed TypeScript wrapper and PDF/EPS/DXF exporters. The identical code runs in a browser and in Node, so a page can convert images without uploading them anywhere.
Licence — read this before you install it
Free, with no time limit, for noncommercial use under the
PolyForm Noncommercial License 1.0.0, whose full text is LICENSE in this
package. The licence names what that covers: personal study,
research, experiment, hobby projects and amateur pursuits, plus use by any
charitable organization, educational institution, public research organization,
public safety or health organization, environmental protection organization, or
government institution.
32 days to evaluate it at work, under
PolyForm Free Trial 1.0.0, whose full text is LICENSE-FREE-TRIAL in this
package,
granted alongside the above. In its words: use to evaluate whether the software
suits a particular application for less than 32 consecutive calendar days, on
behalf of you or your company, is use for a permitted purpose. It does not
permit redistribution — it is for trying, not for shipping.
Anything else commercial needs a written licence. That includes embedding this package in a product or service offered to third parties for a fee, whether or not raster-to-vector conversion is the part you charge for, and a company's own internal business use. Ask: [email protected]
Your rights to this package come from LICENSE and, for commercial use, from a
written agreement with the copyright holder. No web page grants them — not this
project's, and not anyone else's — so nothing published at any address can widen
or narrow what LICENSE says.
THIRD-PARTY-NOTICES.md carries the notices for the Rust crates statically
linked into the WebAssembly modules; they keep their own permissive terms.
The hosted service
vectorize.dudko.dev is this core running in your browser: pick an image, get the drawing, and the file never leaves the tab. It is the quickest way to see what this package does before installing it.
For a pipeline there is an HTTP API at
vectorize.dudko.dev/api — SVG, PDF, EPS and
DXF out, the same options as here — and an MCP endpoint at
https://vectorize.dudko.dev/mcp for an assistant that should run the
conversion rather than read the picture. Both need an account at
auth.dudko.dev, which is free to make and comes with
an allowance the site shows you.
A paid account carries commercial permission for that service. It is not a licence for this package: running the software yourself is the written licence above.
Documents rather than pictures: pdf2md.dudko.dev
turns a PDF into Markdown the same way, with
@dudko.dev/pdf-to-md-core
as its package.
Install
npm i @dudko.dev/vectorize-coreUse
import { traceEncoded, toPdf } from '@dudko.dev/vectorize-core';
const result = await traceEncoded(pngBytes, { preset: 'logo', maxColors: 16 });
result.svg; // '<svg …>'
result.pathCount; // number of paths
result.palette; // ['#1478dc', …]
const pdf = toPdf(result, { dpi: 300 });Presets are logo (flat marks, icons, UI), clipart (drawn artwork, brush
strokes, stickers), photo, sketch (pencil and other greyscale drawings,
traced in six grey levels), bw (line art and scans, black and white), pixel
(pixel art: every pixel a square, every colour exact) and stamp (a stamp, a
signature or handwriting: one ink in its own colour, the paper transparent);
suggestPreset picks one from the pixels (never stamp), and every individual option can be
overridden alongside them. poster, the old name of logo, is still accepted.
detail: 'low' | 'medium' | 'high' scales a preset's colour count, speckle
size and smoothing together, before any option set by hand. A source under
400 px on its shorter side is enlarged before tracing unless upscale says
otherwise.
traceRgba and traceImageData take pixels instead of an encoded file, and
both accept an onProgress callback.
Threads
initThreaded switches to the multi-threaded module, which needs a
cross-origin-isolated page (self.crossOriginIsolated === true, which means the
page is served with Cross-Origin-Opener-Policy: same-origin and
Cross-Origin-Embedder-Policy: require-corp). Without isolation it falls back to
the single-threaded module silently, so tracing still works — just on one core.
Exports
toPdf, toEps and toDxf build their formats from the same traced shapes;
withSize rewrites an SVG's dimensions for a target DPI, unit and width.
