MCPcopy Index your code
hub / github.com/Vibrant-Colors/node-vibrant

github.com/Vibrant-Colors/node-vibrant @v4.0.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.0.4 ↗ · + Follow
232 symbols 475 edges 79 files 27 documented · 12% 4 cross-repo links updated 5mo agov4.0.4 · 2026-01-27★ 2,43620 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

node-vibrant

Join the discussion on Github Best of JS

Extract prominent colors from an image.

  • Identical API for node.js, browser, and worker environments

Install

$ npm install node-vibrant

Usage

// Node
import { Vibrant } from "node-vibrant/node";
// Browser
import { Vibrant } from "node-vibrant/browser";
// Web Worker
import { Vibrant } from "node-vibrant/worker";

// Using builder
Vibrant.from("path/to/image")
    .getPalette()
    .then((palette) => console.log(palette));

// Using constructor
let v = new Vibrant("path/to/image", opts);
v.getPalette().then((palette) => console.log(palette));

Worker Usage

Quantization is the most time-consuming stage in node-vibrant. Luckily, the quantization can be run in the WebWorker to avoid freezing the UI thread.

Here's how to use this feature:

import { Vibrant, WorkerPipeline } from "node-vibrant/worker";
import PipelineWorker from "node-vibrant/worker.worker?worker";

Vibrant.use(new WorkerPipeline(PipelineWorker as never));

This requires your bundler to handle ?worker transforms similar to how Vite does

Documentation

Docs can be seen currently in the docs folder. It includes reference docs and step-by-step guides.

We also have a few examples that you can reference for your needs.

PRs welcomed to expand either of these!

Notes

Result Consistency

The results are consistent within each user's browser instance regardless of the visible region or display size of an image, unlike the original vibrant.js implementation.

However, due to the nature of the HTML5 canvas element, image rendering is platform/machine-dependent. The resulting swatches may vary between browsers, Node.js versions, and between machines. See Canvas Fingerprinting.

The test specs use CIE delta E 1994 color difference to measure inconsistencies across platforms. It compares the generated color on Node.js, Chrome, Firefox, and IE11. At quality == 1 (no downsampling) with no filters and the results are rather consistent. Color diffs between browsers are mostly not perceptible by the human eye. Downsampling will cause perceptible inconsistent results across browsers due to differences in canvas implementations.

Extension points exported contracts — how you extend this code

Pipeline (Interface)
(no doc) [4 implementers]
packages/vibrant-core/src/pipeline/index.ts
WorkerRequest (Interface)
(no doc)
packages/vibrant-worker/src/common.ts
ImageData (Interface)
(no doc)
packages/vibrant-image/src/index.ts
BrowserCommands (Interface)
(no doc)
packages/node-vibrant/__tests__/vibrant.browser.spec.ts
Dimension (Interface)
(no doc)
packages/vibrant-quantizer-mmcq/src/vbox.ts
Filter (Interface)
(no doc)
packages/vibrant-color/src/index.ts
GeneratorOptions (Interface)
(no doc)
packages/vibrant-generator-default/src/index.ts
QuantizerOptions (Interface)
(no doc)
packages/vibrant-quantizer/src/index.ts

Core symbols most depended-on inside this repo

push
called by 12
packages/vibrant-quantizer-mmcq/src/pqueue.ts
hslToRgb
called by 9
packages/vibrant-color/src/converter.ts
count
called by 8
packages/vibrant-quantizer-mmcq/src/vbox.ts
load
called by 7
packages/vibrant-image/src/index.ts
map
called by 7
packages/vibrant-quantizer-mmcq/src/pqueue.ts
size
called by 6
packages/vibrant-quantizer-mmcq/src/pqueue.ts
_findColorVariation
called by 6
packages/vibrant-generator-default/src/index.ts
_getContext
called by 5
packages/vibrant-image-browser/src/index.ts

Shape

Method 117
Function 53
Interface 33
Class 29

Languages

TypeScript100%

Modules by API surface

packages/vibrant-core/src/pipeline/index.ts22 symbols
packages/vibrant-image-browser/src/index.ts19 symbols
packages/vibrant-color/src/index.ts18 symbols
packages/vibrant-image/src/index.ts17 symbols
packages/vibrant-image-node/src/index.ts15 symbols
packages/vibrant-core/src/builder.ts14 symbols
packages/vibrant-quantizer-mmcq/src/vbox.ts13 symbols
packages/vibrant-color/src/converter.ts12 symbols
packages/vibrant-quantizer-mmcq/src/pqueue.ts10 symbols
packages/vibrant-worker/src/pool.ts9 symbols
packages/vibrant-generator-default/src/index.ts9 symbols
packages/vibrant-core/src/index.ts9 symbols

For agents

$ claude mcp add node-vibrant \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page