dominant-colors

A library that excepts an image and a number n and displays n dominant colors for this image.

Usage no npm install needed!

<script type="module">
  import dominantColors from 'https://cdn.skypack.dev/dominant-colors';
</script>

README

dominant-colors

General

Get dominant colors for images.

Author: marina.eremina@bitcomp.fi

Maintainer: marina.eremina@bitcomp.fi

Install

npm install dominant-colors

Usage


// import dominant-colors
const dominantColors = require('dominant-colors');

// imageUrl - path to the image
// maxColorNumber - number of dominant colors to display (up to 12 colors)
dominantColors.showColors(imageUrl, maxColorNumber)
  .then(colors => {
    // colors is an array of hsla color codes
    // for example: ['hsla(0, 0%, 0%, 1)', 'hsla(0, 0%, 100%, 1)'];
  })
  .catch(error => {
    // handle error
  });