Socket
Socket
Sign inDemoInstall

quantize

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    quantize

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


Version published
Weekly downloads
107K
decreased by-17.61%
Maintainers
1
Install size
19.9 kB
Created
Weekly downloads
 

Readme

Source

quantize

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

Install

npm install quantize

Quick Overview

###Usage

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.

// 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.

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

Author

  • Olivier Lesnicki

Contributors

License

Licensed under the MIT License.

Keywords

FAQs

Last updated on 06 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc