@seon82/color-reduce
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

color-reduce

color-reduce provides wasm bindings to the rust implementation of color-reduce, which is used to map image colors to a given palette as fast as possible.

Installation

npm i @seon82/color-reduce

Quickstart

const {process, QuantizeMethod} = require("@seon82/color-reduce");
const fs = require('fs')

// B&W palette
const palette = [[2555,255,255], [0,0,0]]

fs.readFile("cat.jpg", (err, data) => {
  if (err) throw err;
  // No dithering, redmean color distance
  processed_data = process(data, palette, QuantizeMethod.Redmean, false)
  // Dither
  // processed_data = process(data, palette, QuantizeMethod.Redmean, true, 0.2)

  fs.writeFile("cat_processed.jpg", processed_data, (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
  })
});

Package Sidebar

Install

npm i @seon82/color-reduce

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

2.61 MB

Total Files

27

Last publish

Collaborators

  • seon82