Img2Num JS/WASM Bindings (Internal Developer Docs)  dev
API Documentation
JavaScript/WASM Bindings

Introduction

The Img2Num library provides powerful image processing and vectorization capabilities. With the addition of JavaScript and WebAssembly (WASM) bindings, it is now easy to integrate Img2Num into web applications, enabling image processing in the browser with high performance.

These bindings expose the core functionality of Img2Num to JavaScript, allowing developers to access image processing functions directly in the browser or via Node.js environments. WASM provides near-native performance for resource-intensive tasks like Fast Fourier Transforms (FFT) and contour tracing.

Key Features

The JS/WASM bindings offer the following key features:

  • Direct browser access to Img2Num's image vectorization functions.
  • Performance optimized with WebAssembly for fast computation.
  • Cross-platform: Works seamlessly on all major browsers and Node.js environments.
  • Memory safety provided by the WASM wrapper, ensuring no manual memory management is required.

Building JS/WASM Bindings

To build the JavaScript/WASM bindings, follow these steps:

emcmake cmake -B build-wasm
cmake --build build-wasm

For extensive documentation, please see the project setup guide

This will generate the necessary WASM files for use in JavaScript. You can then integrate them into your web projects or Node.js applications.

Installation

The JS/WASM bindings can be installed using the following commands:

cmake --install build-wasm

After installation, you will find the WASM module and JavaScript wrapper in the {{LIB_PATH}} directory.

Usage

Usage of these raw bindings is discouraged. The Img2Num JavaScript library wraps these bindings safely for you. If you are looking to using it, see the relevant documentation.

Each function exposed to JavaScript provides a simple interface for interacting with the core Img2Num library functions in the browser or Node.js.