1.1.1 • Published 1 year ago

color-thief-ts v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Color Thief

Grab the color palette from an image using just Javascript.Works in the browser & node.

Getting Started

install

yarn add color-thief-ts

or

npm install color-thief-ts

example for browser

import ColorThief from "color-thief-ts";

const colorThief = new ColorThief();
const dominantColor = await colorThief.getColorAsync("your-domaon/your-image-url.jpg");
const palette = await colorThief.getPaletteAsync("your-domaon/your-image-url.jpg", 5);

console.log(dominantColor);
console.log(palette);

example for node.js

import ColorThief from "color-thief-ts/node";
import fetch from "node-fetch";
import Sharp from "sharp";

const colorThief = new ColorThief();

const image = await fetch("http://localhost:3000/images/example.png")
  .then((res) => res.arrayBuffer())
  .then((arrayBuffer) => Buffer.from(arrayBuffer));

const palette1 = await colorThief.getPalette(
  { type: "image/png", buffer: image },
  5
);

const palette2 = await colorThief.getPalette(
  "http://localhost:3000/images/example.png",
  5
);

const palette3 = await colorThief.getPalette(
  "./images/example.png",
  5
);

const color = await colorThief.getColor(
  { type: "image/png", buffer: image }
);
1.1.1

1 year ago

1.1.0

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago