A modern ESM build of the Potrace library for use in the browser.

Overview

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.

SVGcode application screenshot

License

⚠️ GPL-v2.0, due to the original Potrace 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.

Comments
  • Create colored svg in c++ code.

    Create colored svg in c++ code.

    • Create colored svg in c++ code. Basically it is simillar algoritm from repo https://github.com/tomayac/SVGcode The porpouse was to speedup colored svg by using c++ code.
    • Create building scripts for windows platform
    • Use em++ compiler to use c++ language
    opened by sylmroz 11
  • The vectorizalisad image returned by the package is composed of

    The vectorizalisad image returned by the package is composed of "dots" (first image attached). How can I have a more "uniform" result instead?

    Hello, I have a question on how to improve the result returned by the package, and thought someone here may help.

    The result returned by the package is composed of a lot of small dots, here is the attachment: dots

    However, I would link to obtain a more "uniform" result, link this other attachement: nodots

    Does someone know how I could achieve it?

    Thanks very much

    opened by damiano216 5
  • Possible to remove `document.body.append(canvas)`?

    Possible to remove `document.body.append(canvas)`?

    Hi, thanks for this fork! I was wondering if it would be possible to remove the call to document.body.append(canvas) on Line 86 so it doesn't automatically add a canvas node to the page? Or would that break something?

    opened by kenfehling 1
  • Add ready() to fix parallel issue

    Add ready() to fix parallel issue

    This PR exports the ready() module function we'll use to allow parallel computing. This will be used to fix https://github.com/tomayac/SVGcode/issues/20

    Basically all it's needed after that is to call await ready() before calling multiple times potrace() in parallel.

    @tomayac Please review.

    opened by beaufortfrancois 0
  • Bug: Image size limit

    Bug: Image size limit

    This library produces a "RangeError: offset is out of bounds" when loading LARGE images. I have not isolated the break point, but for reference this image will definitely cause the problem condition and I'm sure I could find examples where it occurs on images half that size. Changing input options does not fix the problem. (Using safari and chrome on mac)

    opened by foomoon 3
  • Try again with proper build

    Try again with proper build

    @connorjclark This is a second attempt. I guess I simply don't get what to do with Module. I tried to follow this example, but not sure it's applicable.

    The main idea is to get rid of this hack, where I append export { potrace, ready as init }; to the output: https://github.com/tomayac/esm-potrace-wasm/blob/7d81a9c19ed74fe135107a9328b7adc58a5b8f57/package.json#L25

    The proper way to get a module seems to be -s "MODULARIZE=1" -s "EXPORT_ES6=1".

    opened by tomayac 0
Owner
Thomas Steiner
Developer Relations Engineer at @Google—focused on the Web and Project Fugu 🐡. Dad-of-3. Alum of @UniversiteLyon (Postdoc), @la_UPC (PhD), @KITKarlsruhe (MA)
Thomas Steiner
A static C library to build applications for the Foenix retro computers, and, eventually, a single-tasking operating system and file browser that sits atop the Foenix MCP Kernel

@mainpage Foenix A2560 Foenix Retro OS: fr/OS A2560-FoenixRetroOS This project provides 2 things: A static C library/framework that anyone can use to

null 4 Jun 24, 2022
an easy-to-use cross platform web browser controller for C++

WebBrowser++ 这是一个基于C++17的唯头文件跨平台浏览器控制库。 您只需要将本目录下的Include文件夹拷贝至您的项目中即可使用。如果使用CMake编译,则可直接include_directories(Include),也可以模仿本项目的CMakeLists.txt进行编写。 建立该

null 8 Nov 17, 2021
A Minimal Web Browser with Built-in Adblocker in Less Than 100 Lines of Code

A Minimal QtWebEngine Web Browser with Adblocker How Does It Work This is a minimal network filter implementation using QWebEngineUrlRequestIntercepto

Penk Chen 19 Jul 23, 2022
Filter and launch links in a browser of your choice!

Link Launcher Filter links with regular expressions and launch them into your favourite browsers Have you ever wanted to open a youtube link from othe

null 5 Aug 20, 2021
A homebrew browser that's actually good.

Better Homebrew Browser The homebrew browser that's actually good. Massive thanks to GrapheneCt on his work on ScePaf. Features It is the second ever

Ibrahim 66 Nov 28, 2022
Surf - simple webkit-based browser

Surf - simple webkit-based browser

Johannes Hove-Henriksen 1 Nov 21, 2021
An easy programming language that runs in the browser

easylang.online An easy programming language that runs in the browser Website easylang.online Build in Linux Dependencies Download Emscripten SDK and

chkas 94 Nov 21, 2022
Scriptable Headless Browser

PhantomJS - Scriptable Headless WebKit PhantomJS (phantomjs.org) is a headless WebKit scriptable with JavaScript. The latest stable release is version

Ariya Hidayat 29.1k Nov 30, 2022
An old-style web browser stub, comes from Internet Explorer was genocided on Windows.

Outernet Explorer An old-style web browser stub, comes from Internet Explorer was genocided on Windows. Download from: https://github.com/kekyo/Outern

Kouji Matsui 11 Oct 14, 2022
QtWebKit-based web browser on Linux framebuffer.

FBrowser QtWebKit-based web browser on Linux framebuffer. Security Notes This browser is not intended for visiting untrusted websites. By default, OSB

null 22 Nov 7, 2022
Browser and NodeJS Web Assembly audio decoder libraries that are highly optimized for size and performance.

WASM Audio Decoders WASM Audio Decoders is a collection of Web Assembly audio decoder libraries that are highly optimized for browser use. Each module

Ethan Halsall 70 Oct 29, 2022
Template for C++ GUI apps that can run in the browser

GGWeb Template for making a GUI app with C++ / Dear ImGui / SDL / OpenGL / Emscripten that can run both natively and in the browser. Example: https://

Georgi Gerganov 22 Nov 21, 2022
Clean tab-less browser based on webkit2 and GTK4.

Rose Browser Simple browser based on webkit2-5.0/GTK4. Showcase Requirements In order to build rose you need gtk4 and webkit2gtk-5.0. In order to use

Rosé 275 Nov 19, 2022
Libft is an individual project at 42 that requires us to re-create some standard C library functions including some additional ones that can be used later to build a library of useful functions for the rest of the program.

Libft is an individual project at 42 that requires us to re-create some standard C library functions including some additional ones that can be used later to build a library of useful functions for the rest of the program.

Paulo Rafael Ramalho 0 Apr 5, 2022
Library of useful C++ snippets and reusable classes I've created as I build out Arduino Uno and ESP32 projects.

Arduino Snippets Library of useful C++ snippets and reusable classes I've created as I build out Arduino Uno and ESP32 projects. Button A simple butto

Max Lynch 7 Feb 5, 2022
build-once run-anywhere c library

Cosmopolitan Cosmopolitan Libc makes C a build-once run-anywhere language, like Java, except it doesn't need an interpreter or virtual machine. Instea

Justine Tunney 9.9k Nov 30, 2022
Simple template project to build a firmware for the STM32F4 Discovery board with FreeRTOS and libopencm3

STM32F4 Discovery FreeRTOS Makfile This is a simple template project to build a firmware for the STM32F4 Discovery board with FreeRTOS and libopencm3

Andrea Colla 8 May 22, 2022
A simple-to-build ortholinear keyboard named after a famous penguin

Nils Olav A simple-to-build, low-profile, ortholinear keyboard named after a famous penguin. This keyboard is based around the Elite-C v4. It features

Andrew Harvie 9 May 27, 2022
PNPASSIST: A “SMART” BUILD PLATFORM FOR MANUAL PCB ASSEMBLY

PnPAssist Description The PnPAssist is an open source innovative CNC table that position the next SMT component with a proper orientation for you to m

MakerStorage 37 Nov 18, 2022