Skip to content

Releases: lokesh/color-thief

v3.3.0

04 Mar 19:28

Choose a tag to compare

Adds colorthief CLI with color, palette, and swatches subcommands. Supports --json, --css, and ANSI output formats, stdin piping, multi-file input, and a friendly error message when sharp is not installed.

image

v3.2.0

04 Mar 17:49

Choose a tag to compare

Browser bundlers no longer warn about sharp - Bundlers like webpack (Angular), Vite, and Rollup previously emitted a "Can't resolve 'sharp'" warning when using colorthief in browser-only projects. The library now ships separate browser builds that contain no references to sharp or Node.js-specific code. Bundlers automatically pick the right build via the "browser" condition in package.json exports. No changes needed on your end. The API is identical. (#279)

v3.1.0

04 Mar 17:05

Choose a tag to compare

Changed palette functions to default to utilizing OKLCH (previously RGB)

v3.0.0

02 Mar 04:45
a79371f

Choose a tag to compare

Full TypeScript rewrite with a unified browser + Node.js API.

Highlights:

  • Rich Color objects with .hex(), .rgb(), .hsl(), .oklch(), .css()
  • OKLCH perceptually uniform quantization
  • Semantic swatches (Vibrant, Muted, DarkVibrant, DarkMuted, LightVibrant, LightMuted)
  • Live extraction with observe() for video, canvas, and img elements
  • Web Worker offloading
  • Progressive 3-pass extraction
  • WCAG contrast ratios and text color recommendations
  • AbortSignal support
  • Zero runtime dependencies

v.2.7.0

28 Feb 09:03

Choose a tag to compare

New features:

  • Configurable pixel filtering — New options: ignoreWhite, whiteThreshold, alphaThreshold, and minSaturation let callers control which pixels are
    included in color extraction
  • Options object API — getColor and getPalette now accept an options object (e.g., { colorCount: 5, quality: 10, ignoreWhite: false }) in addition to the
    existing positional arguments
  • New browser input types — getPalette/getColor now accept HTMLCanvasElement, ImageData, and ImageBitmap in addition to HTMLImageElement
  • TypeScript type definitions — Added .d.ts files for both browser (color-thief.d.ts) and Node (color-thief-node.d.ts)

Bug fixes & robustness:

  • Fallback color for edge cases — New computeFallbackColor() averages all pixels when the quantizer can't produce a palette (e.g., solid-color or
    all-white images), preventing null returns
  • Progressive filter relaxation — If filtering removes all pixels, filters are progressively relaxed (first allowing white, then transparent) before
    falling back
  • Fixed variable scope leak — i in getImageData changed from implicit global to let
  • Input validation — Browser version now throws descriptive errors for unloaded images, missing sources, and CORS-tainted canvases
  • Null-safe palette access — All call sites now check palette for null before accessing palette[0]

Chores & tooling:

  • Removed file-type dependency from Node version (unused)
  • Removed dist/ from git tracking (kept in npm package via .npmignore)
  • Added GitHub Actions CI workflow
  • Replaced CanvasImage class with a simpler getPixelData() function
  • Updated README to reflect current project setup
  • Version bump to 2.7.0 across package.json and source files

v2.6.0

09 Oct 19:17

Choose a tag to compare

What's Changed

  • deps: switch get-pixels for ndarray-pixels in #263

Original PR by @briandonahue #254

Full Changelog: v2.5.0...v2.6.0

v2.5.0

09 Oct 18:01

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v2.4.0...v2.5.0

v2.4.0

28 Feb 22:12

Choose a tag to compare

What's Changed

  • build: resolve Quantize dep issue, upgrade Cypress by @lokesh in #233

Full Changelog: v2.3.2...v2.4.0

v2.3.2

06 Jul 04:32

Choose a tag to compare

fix: Use image naturalHeight and naturalHeight #182 Thanks to @wangcheng

v2.3.1

06 Jul 02:32
4858a20

Choose a tag to compare

  • #191 fix: quality option validation. Thanks to @aaron-hanson Issue
  • chore: Fix npm script command syntax. Thanks again to @aaron-hanson
  • tests: Add test for CORS
  • docs: Move contributing info inline in README. Add proj structure and more info around testing.