PLAN.md
Improvements that ship under the current API contract. No breaking changes. Existing consumers upgrade without code changes.
null. getColor() should return the dominant remaining color (or the image's actual color if filtering removed everything). getPalette() should return a shorter array rather than crash.src/color-thief.js:120 — i = uInt8Array.length is missing let, creating an implicit global.dist/color-thief.d.ts and dist/color-thief-node.d.ts alongside the existing JS output.types field to package.json..d.ts files that match the current API.Expand what getColor() and getPalette() accept beyond HTMLImageElement:
HTMLCanvasElementImageDataImageBitmapThese are additive — existing code passing `` elements still works.
Expose the hardcoded thresholds as optional config:
ignoreWhite (default true, current behavior) — with configurable RGB threshold (default 250)alphaThreshold (default 125) — pixels below this alpha are skippedminSaturation (default 0) — optional minimum saturation filterPass as an options object: getColor(image, { quality: 10, ignoreWhite: false }). The current positional args (quality, colorCount) continue to work for backward compat.
ecmaVersion from 2018 to current.color-thief.min.js copy — or actually minify it.A new major version. Different API surface, new output format, modern JS throughout. Published as a new major version with a migration guide.
getColor() and getPalette() return Promises on both browser and Node.getColorFromUrl(), getColorAsync(), and getImageData(). Image loading is the consumer's responsibility.XMLHttpRequest with fetch() if any internal HTTP calls remain.AbortController / AbortSignal for cancellation.Replace bare [r, g, b] arrays with color objects:
const color = await colorThief.getColor(image);
color.rgb() // { r, g, b }
color.hex() // '#e84d3d'
color.hsl() // { h, s, l }
color.oklch() // { l, c, h }
color.array() // [r, g, b] (backward-compat escape hatch)
color.isDark // boolean
getPalette() returns an array of these objects.
Add a getSwatches() method that classifies palette colors into UI roles:
OffscreenCanvas + createImageBitmap to move pixel reading and quantization off the main thread.getColor(image, { worker: true }).sharp as a hard dependency. It's heavy (native bindings, Docker/CI build issues).sharp as an optional peer dependency for users who already have it.@colorthief/wasm package with the quantization algorithm compiled from Rust.colorthief package stays pure JS with zero native dependencies.isDark / isLight booleangetColor(image, { progressive: true }) returns an async iterator or observable that emits improving results.