splashy

Given an image, extract predominant & palette colors

Usage no npm install needed!

<script type="module">
  import splashy from 'https://cdn.skypack.dev/splashy';
</script>

README

microlink cdn

Last version Coverage Status NPM Status

Given an image, extract predominant & palette colors.

Install

$ npm install splashy --save

Usage

From URL

(async () => {
  const splashy = require('splashy')
  const got = require('got')

  const url = 'https://kikobeats.com/images/avatar.jpg'
  const { body } = await got(url, { responseType: 'buffer' })
  const palette = await splashy(body)

  console.log(palette)
  // => [ '#941c1c', '#841c16', '#aa695e', '#ca866c', '#6c5444', '#cca4a4' ]
})()

From Buffer

(async () => {
  const splashy = require('splashy')
  const path = require('path')
  const fs = require('fs')

  const filepath = path.resolve(__dirname, 'avatar.jpg')
  const buffer = await fs.readFile(filepath)
  const palette = await splashy(buffer)

  console.log(palette)
  // => [ '#941c1c', '#841c16', '#aa695e', '#ca866c', '#6c5444', '#cca4a4' ]
})()

API

splashy(input)

input

Required
Type: ImageSource

The raw content for detecting the color information.

Related

License

microlink-function © Microlink, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

microlink.io · GitHub @MicrolinkHQ · Twitter @microlinkhq