Socket
Socket
Sign inDemoInstall

@symbo.ls/quantize

Package Overview
Dependencies
Maintainers
7
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@symbo.ls/quantize

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


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
7
Weekly downloads
 
Created
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

Package last updated on 17 Nov 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc