# quantize

> A node.js module for color quantization, based on Leptonica.

Latest version **1.0.2** (published 2016-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install quantize
pnpm add quantize
yarn add quantize
bun add quantize
```

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-04-06 |
| First published | 2014-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/quantize) |
| Module format | CommonJS |
| Node | >=0.10.21 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 157 |
| Author | Olivier Lesnicki |
| Maintainers | olivierlesnicki |
| Keywords | image, quantize, color, node |

## Links

- npm: https://www.npmjs.com/package/quantize
- Repository: https://github.com/olivierlesnicki/quantize
- Issues: http://github.com/olivierlesnicki/quantize/issues
- npm.io page: https://npm.io/package/quantize

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2016-04-06
- 1.0.1 — 2014-02-07
- 1.0.0 — 2014-02-06

## README

quantize
========

Node.js module for color quantization, based on Leptonica.

Install
-------

	npm install quantize

Quick Overview
--------------

###Usage

`````javascript
var quantize = require('quantize');

var arrayOfPixels = [[190,197,190], [202,204,200], [207,214,210], [211,214,211], [205,207,207]];
var maximumColorCount = 4;

var colorMap = quantize(arrayOfPixels, maximumColorCount);
`````

* `arrayOfPixels` - An array of pixels (represented as [R,G,B arrays]) to quantize
* `maxiumColorCount` - The maximum number of colours allowed in the reduced palette

#####Reduced Palette

The `.palette()` method returns an array that contains the reduced color palette.

`````javascript
// Returns the reduced palette
colorMap.palette(); 
// [[204, 204, 204], [208,212,212], [188,196,188], [212,204,196]]
`````

#####Reduced pixel

The `.map(pixel)` method maps an individual pixel to the reduced color palette.

`````javascript
// Returns the reduced pixel
colorMap.map(arrayOfPixels[0]);
// [188,196,188]
`````

Author
------

* [Olivier Lesnicki](https://github.com/olivierlesnicki)

Contributors
------------

* [Nick Rabinowitz](https://github.com/nrabinowitz)
* [Mike Bostock] (https://github.com/mbostock)

License
-------

Licensed under the MIT License.

---
_Source: https://npm.io/package/quantize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
