zer0vuln / zbar-wasi

Webassembly (WASI) port of Zbar barcode scanner

Home Page:https://myisaak.github.io/zbar-wasi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zbar-wasi

Node.js CI Code scanning - action npm (tag) Maintenance License: MIT Downloads Total Downloads Month

Scan barcodes in web browsers

This library allows web browsers to scan barcodes with a Webassembly and WASI backend.

Why?

  • Unlike most Webassembly projects this one is compiled with WASI instead of Emscripten.
  • Optimized for size with a WASM binary size of 161.98 KB gzipped (244.40 KB uncompressed).
  • Works perfectly on mobile devices and desktop

Demo

Try scanning barcodes with your camera: https://myisaak.github.io/zbar-wasi/ Watch your command line for found barcodes.

Installation

npm install zbar-wasi

Usage

import { scanImage, createZbar } from "zbar-wasi";

const start = async () => {
  // move ./node_modules/zbar-wasi/dist/zbar.wasm to your web directory"
  const ZBAR = await createZbar({ wasmpath: "./zbar.wasm" });
  const imageData = ctx.getImageData(0, 0, width, height);
  const results = scanImage(imageData);
  console.log(results);
  // outputs [ barcode1, barcode2, ... ]
}
start();

About

Webassembly (WASI) port of Zbar barcode scanner

https://myisaak.github.io/zbar-wasi


Languages

Language:JavaScript 33.9%Language:C 25.6%Language:HTML 20.8%Language:Makefile 9.7%Language:Dockerfile 8.6%Language:Shell 1.2%