cquant-web
Preview
Usage
Install
npm i cquant-web
API
cQuant
- image: could be a url to an image or a HTML img element
- maxColor: maxColor you want
- result: the result, an array of
{red,blue,green,count}
Config for webpack
Webpack
add rule for WASM file
make sure you have installed the file-loader already
module:rules:test: /\.wasm$/type: "javascript/auto"loader: "file-loader"options:name:'[name].[ext]' // if you want keep the WASM nameresolve:alias:// add alias for WASM importingcQuantWASM: path
Import & Usage
let cquant = WASM true // pass WASM module file path, enable log// pass Image path, and the color amount you wantcquant
Vanilla js
Download
You will need to download the files in dist: cquant.wasm
and index.js
(rename it if you need), or import from github directly.
OR
Usage
Limitation
The cQuant.palette
isnot fully async function actually.
It will load the WASM file async-ly,but the real palette computation will block the thread.
Of course, I'm working on it, web worker seems to be a good choice. \s