MCPcopy Index your code
hub / github.com/briangonzalez/rgbaster.js

github.com/briangonzalez/rgbaster.js @v2.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.1 ↗ · + Follow
11 symbols 21 edges 9 files 0 documented · 0% updated 6y agov2.0 · 2018-12-02★ 1,7506 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

artboard

A dead simple, zero-dependency, promise-based javascript library for extracting the dominant color(s) from an image.

👉 Version 2 was written from the ground up with a clean and modern API, a robust test suite, and is fully written in Typescript.

Installation

npm install --save rgbaster

Usage

This library exports a default function which returns a promise that resolves to a sorted array with the most dominant color at index 0, secondary at index 1, so on and so forth.

[
  { color: 'rgb(0,0,255)', count: 86  },
  { color: 'rgb(9,18,42)', count: 32  },
  { color: 'rgb(120,8,202)', count: 3  },
]
import analyze from 'rgbaster'

const result = await analyze('/2px-blue-and-1px-red-image.png') // also supports base64 encoded image strings

console.log(`The dominant color is ${result[0].color} with ${result[0].count} occurrence(s)`)
// => The  dominant color is rgb(0,0,255) with 2 occurrence(s)

console.log(`The secondary color is ${result[1].color} with ${result[1].count} occurrence(s)`)
// => The  secondary color is rgb(255,0,0) with 1 occurrence(s)

Configuration options

You may pass an optional second parameter, an object, with the following options:

ignore

An array of colors to ignore (in the form of rgb) when counting colors.

const result = await analyze('/image.png', { ignore: [ 'rgb(255,255,255)', 'rgb(0,0,0)' ] })

scale

In order to achieve greater speed, you can have rgbaster scale down the image we use internally prior to analysis, thus decreasing accuracy.

const result = await analyze('/image.png', { scale: 0.6 })

Browser support

rgbaster depends on the following browser functionality:

Maintainers

About

rgbaster was created to modularize adaptive backgrounds. Check it out.

License

MIT

Extension points exported contracts — how you extend this code

Opts (Interface)
(no doc)
src/index.ts

Core symbols most depended-on inside this repo

step
called by 4
src/index.js
verb
called by 3
src/index.js
getContext
called by 1
src/helpers.ts
getImageData
called by 1
src/helpers.ts
getCounts
called by 1
src/helpers.ts
fulfilled
called by 0
src/index.js
rejected
called by 0
src/index.js
default_1
called by 0
src/index.js

Shape

Function 10
Interface 1

Languages

TypeScript100%

Modules by API surface

src/index.js5 symbols
src/helpers.ts4 symbols
src/index.ts1 symbols
src/helpers.js1 symbols

For agents

$ claude mcp add rgbaster.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page