Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pixel-color-cruncher

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixel-color-cruncher

Given an image, find a palette of colors. Uses a median-cut algorithm

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

#Pixel Color Cruncher

Given an image, gives you the a palette of colors from it. A median-cut color quantization implementation.

Demo

See it in action here: demo!

To use

Pixel cruncher is a WebWorker.

// create web worker
var pixelCruncher = new Worker('/js/pixel-cruncher.js'); // or wherever pixel-cruncher.js is located

pixelCruncher.addEventListener('message', function(e){
    var colors = e.data;

    // returns an array of [r,g,b] colors that you can now use
    doSomethingWith(colors);
});

// spawn worker thread to crunch pixels. num_colors must be multiple of 2
pixelCruncher.postMessage({data: imageData, num_colors: 16});

Refer to js/main.js for a usage example.

Credits

Shoutout to Giorgio who paired on me with this!

Keywords

FAQs

Package last updated on 14 Sep 2015

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