ESM Potrace Wasm
A modern ESM build of the Potrace library for use in the browser.
Installation
npm install --save esm-potrace-wasm
Usage
import potrace from 'esm-potrace-wasm';
/**
* The `imageBitmapSource` parameter is an `ImageBitmapSource`, that is any of:
* - `HTMLImageElement`
* - `SVGImageElement`
* - `HTMLVideoElement`
* - `HTMLCanvasElement`
* - `ImageData`
* - `ImageBitmap`
* - `Blob`
*/
const svg = await potrace(
imageBitmapSource,
(options = {
turdsize: 2,
turnpolicy: 4,
alphamax: 1,
opticurve: 1,
opttolerance: 0.2,
pathonly: false,
})
);
Developing
Modify src/potrace/
and run npm run build
to update the ESM build in dist/
. The emscripten build file is located at ./build.sh
. A simple demo that imports dist/index.js
is available in demo/
and can be started by running npm start
.
Apps using this
This library is used in SVGcode.

License
Acknowledgements
Based on @nturley's fork of @IguteChung's initial potrace-wasm. Unfortunately, the original author did not react on my Pull Request, so I forked.