Socket
Socket
Sign inDemoInstall

color-finder

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    color-finder

This class can get you a common color from the image by url. But be careful of ussing this as there are Cross Origin policy which may block some images from different domains.


Version published
Maintainers
1
Install size
140 kB
Created

Readme

Source

color-finder Build Status Coverage Status

This class can get you a common color from the image by url. But be careful of ussing this as there are Cross Origin policy which may block some images from different domains.

Live Demo: http://preview.16mb.com/color-finder/

Installation

Using bower:

bower install color-finder --save

Using npm:

npm install color-finder

or just download latest release from Github.

Usage

ColorFinder.fromImage('http://....jpg', function(color) {...})

color is an array which contains RGB value (ex. [234, 48, 255]).

Additional Configuration

You can specify maximum value for RGB complement by calling:

ColorFinder.setConfig('maxColorValue', 230) type:Number [230 by default]

Here 230 will be limit for every color complement (R < 230, G < 230, B < 230).

ColorFinder.setConfig('quality', 10) type:Number [10 by default]

quality will affect amount of pixels being processed to determine common color. This value may affect performance.

ColorFinder.setConfig('colorsAmount', 10) type:Number [10 by default]

colorsAmount also affects the quality of final color but in later stage of quantization process. This value does not affect performance ( if colorsAmount is in good range (= ).

ColorFinder.setConfig('useWebWorker', true) type:Boolean [true by default]

useWebWorker will perform all heavy calculations in Web Worker thread if available in browser

ColorFinder.setConfig('workerPrefixPath', "") type:String ["" (empty string) by default]

workerPrefixPath will be added to the url path to web worker. In case you have different url path - you can use this value to make worker work.

Development

To build this package run gulp

To run tests run npm test

Known Issues

  • You may face an issue when a callback function did not invoke at all.
    Most probably the web worker is not loaded properly (you can verify that by checking browser and server requests log). If that is a problem - correct path to web worker by setting ColorFinder.setConfig('workerPrefixPath', "your/path/") to right url prefix.

Credits

Author

Alex Malkevich

FAQs

Last updated on 29 Mar 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