Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomayac/esm-potrace-wasm
A modern ESM build of the Potrace library for use in the browser.
https://github.com/tomayac/esm-potrace-wasm
javascript potrace potrace-js potrace-port wasm
Last synced: 3 days ago
JSON representation
A modern ESM build of the Potrace library for use in the browser.
- Host: GitHub
- URL: https://github.com/tomayac/esm-potrace-wasm
- Owner: tomayac
- License: gpl-2.0
- Created: 2021-09-14T11:56:18.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-29T15:17:33.000Z (about 1 year ago)
- Last Synced: 2024-10-17T17:30:16.247Z (17 days ago)
- Topics: javascript, potrace, potrace-js, potrace-port, wasm
- Language: C
- Homepage: https://tomayac.github.io/esm-potrace-wasm/demo/index.html
- Size: 1.62 MB
- Stars: 71
- Watchers: 3
- Forks: 12
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ESM Potrace Wasm
A modern ESM build of the [Potrace](http://potrace.sourceforge.net/) library for use in the browser.
## Installation
```bash
npm install --save esm-potrace-wasm
```## Usage
```js
import { potrace, init } from 'esm-potrace-wasm';(async () => {
// Initialize the module once.
await init();/**
* 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,
extractcolors: true,
posterizelevel: 2, // [1, 255]
posterizationalgorithm: 0, // 0: simple, 1: interpolation
})
);
})();
```## 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` (or `build.ps1` for Win32) respectively. 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
⚠️ GPL-v2.0, due to the original [Potrace license](http://potrace.sourceforge.net/#license).
## Acknowledgements
Based on [@nturley](https://github.com/nturley)'s [fork](https://github.com/nturley/potrace-wasm) of
[@IguteChung](https://github.com/IguteChung)'s initial [potrace-wasm](https://github.com/IguteChung/potrace-wasm).
Unfortunately, the original author did not react on my
[Pull Request](https://github.com/IguteChung/potrace-wasm/pull/1), so I forked.