Détail du package

oslllo-potrace

oslllo127kGPL-2.04.0.0

A "1:1 output" JavaScript port of Potrace JS for NodeJS.

potrace, oslllo, potrace-js, potrace-port

readme

Potrace

CI/Test npm

A "1:1 output" JavaScript port of Potrace JS for NodeJS.


Original image Potrace output
Original Image Potrace Output

Online Demo


Why did I create this package ❓

The issue


Prerequisites

  • Node.js v10+

Installation

npm install oslllo-potrace

Basic 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 to image to trace.
  • options (Object): option parameter object.
    • turnpolicy (string): how to resolve ambiguities in path decomposition. available options are [ Potrace.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 are [curve]

Changelog

Please see CHANGELOG for more information what has changed recently.

Test

npm test

Credits

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.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

4.0.0 (2024-10-30)

Bug Fixes

Dependencies

  • deps: update jimp to 1.6.0 (#61)

3.0.0 (2024-07-21)

Bug Fixes

  • fix security vulnerabilities (cd9eee2)

2.0.1 (2022-07-16)

Miscellaneous Chores

2.0.0 (2021-12-31)

Features

  • deps: Simplify dependencies, remove canvas/jsdom (c013c58)

Bug Fixes

  • deps: use svg2png-wasm-node-10 for compatibility (655fe37)
  • example: add white background (f3b3980)

Miscellaneous Chores

1.2.0 (2021-12-30)

Features

  • potrace: new Promise() is not needed with async function (1adad10)

Bug Fixes

  • src: remove unused vars (a00c02a)
  • unhandled rejection in Loader.image() (5edf4a7)
  • unhandled rejection in Loader.image() (0c3843f)

1.1.4 (2021-09-05)

Bug Fixes

1.1.3 (2021-05-06)

Miscellaneous Chores

  • update dependencies
  • release 1.1.3 (f7784aa)

[1.1.2] - 2021/3/31

Security

  • Updated dependences.

[1.1.1] - 2020/12/12

Fixed

  • Fixed vulnerabilities.

[1.1.0] - 2020/9/10

Fixed

  • Added missing package jimp needed on runtime.

[1.0.1] - 2020/9/10

Changed

  • Remove tests from npm package to help reduce unpacked package size.

[1.0.0] - 2020/9/10

Changed

  • Changed potrace.trace(file, options) => Potrace(file, options).trace().
  • Changed new potrace.Potrace() => Potrace(file, options),

    The new declaration for Potrace is no more required.

  • Refactored codebase.
  • Updated tests.
  • Moved tests from jest to mocha.
  • Removed unused dependencies.

Fixed

Security

  • Updated dependences.

[0.0.10] - 2020/7/10

Security

  • Updated dependences.

[0.0.9] - 2020/5/16

Changed

  • Removed unused dependences.

Security

[0.0.8] - 2020/5/14

Changed

  • Reduced npm package size.

[0.0.7] - 2020/5/12

Fixed

  • Fixed typo in core.js.

Added

  • Added badge links to README.md.
  • Added new tags to package.json.

Changed

  • Updated README.md content.

[0.0.6] - 2020/5/6

Changed

  • potrace.Potrace.getSVG() default size can now be set in parameters.
  • Cleaned up tests and code.
  • Updated README.md.

Added

  • Added example tests.

[0.0.5] - 2020/4/29

Changed

  • Updated package.json description to match repo.

[0.0.4] - 2020/4/29

Fixed

  • Fixed issue with potrace.trace() not being able to set parameters.

Changed

  • Refactored tests.
  • Updated README.md.

Added

  • Added new tests.

[0.0.3] - 2020/4/29

Changed

  • Updated README.md.

[0.0.2] - 2020/4/28

Changed

  • Updated README.md.

[0.0.1] - 2020/4/28

Added

  • Added everything, initial release.