JSPM

color-thief-node

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2052
  • Score
    100M100P100Q116287F
  • License ISC

Color thief reimplementation for Node.js

Package Exports

  • color-thief-node

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (color-thief-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Color Thief Node

Color thief reimplementation for Node.js.

The original color thief project relies on the browser Canvas object to extract pixels from images. It does not work well in Node.js environment because the Canvas object does not natively exist in Node.js.

This project, however, relies on the node-canvas library to simulate a Canvas object in Node.js environment. The source code has also been rewritten in ES6 fashion with support for promise.

Test

npm run test

or

yarn test

Installation

npm i color-thief-node

or

yarn add color-thief-node

Usage

Get the Dominant Color from an Image

const { getColorFromURL } = require('color-thief-node');

(async () => {
    const dominantColor = await getColorFromURL(imageURL);
})();

Build a Color Palette from an Image

const { getPaletteFromURL } = require('color-thief-node');

(async () => {
    const colorPallete = await getPaletteFromURL(imageURL);
})();

You can also check out test/index.test.js for more detailed example.