4.0.0 • Published 1 year ago
oslllo-potrace v4.0.0
Potrace
A "1:1 output" JavaScript port of Potrace JS for NodeJS.
| Original image | Potrace output |
|---|---|
![]() | ![]() |
Why did I create this package ❓
Prerequisites
- Node.js v10+
Installation
npm install oslllo-potraceBasic Usage
Taken from Example.js
Example 1
const path = require("path");
const Potrace = require("..");
const fs = require("fs-extra");
const Svg2 = require("oslllo-svg2");
async function example1() {
var source = path.resolve("example/tree.jpg");
var destination = path.resolve("example/tree.svg");
var traced = await Potrace(source).trace();
fs.writeFileSync(destination, traced);
await Svg2(traced).png().extend(10).toFile("example/tree.png");
}
example1().then(() => {
console.log("done");
}).catch((err) => {
throw err;
});Example 2
const path = require("path");
const Potrace = require("..");
const fs = require("fs-extra");
const Svg2 = require("oslllo-svg2");
async function example2() {
var source = path.resolve("example/tree.jpg");
var destination = path.resolve("example/tree.svg");
var instance = Potrace(source);
var traced = await instance.trace();
fs.writeFileSync(destination, traced);
await Svg2(traced).png().extend(10).toFile("example/tree.png");
}
example2().then(() => {
console.log("done");
}).catch((err) => {
throw err;
});Parameters
source(String | Buffer): path toimageto trace.options(Object): option parameter object.turnpolicy(string): how to resolve ambiguities in path decomposition. available options arePotrace.TURNPOLICY_BLACK,Potrace.TURNPOLICY_WHITE,Potrace.TURNPOLICY_LEFT,Potrace.TURNPOLICY_RIGHT,Potrace.TURNPOLICY_MINORITY,Potrace.TURNPOLICY_MAJORITY(default: Potrace.TURNPOLICY_MINORITY).turdsize: (Number) suppress speckles of up to this size (default: 2).optcurve: (Boolean) turn on/off curve optimization (default: true).alphamax: (Number) corner threshold parameter (default: 1).opttolerance: (Number) curve optimization tolerance (default: 0.2).svgSize: (Number) set svg output size. NOTE:The resulting image size=the original image size*size(default: 1).opt_type: (String) output svg type, available options arecurve
Changelog
Please see CHANGELOG for more information what has changed recently.
Test
npm testCredits
Potrace JS Port by @kilobtye.
Original Potrace by Peter Selinger.
Another Potrace Port For Node.js maintained by @tooolbox.
License
The GNU General Public License v2.0 (GPL-2.0). Please see License File for more information.
4.0.0
1 year ago
3.0.0
1 year ago
2.0.1
3 years ago
1.2.0
4 years ago
2.0.0
4 years ago
1.1.4
4 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
0.0.10
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago

