Get colour palette from an image.
npm install @liquid-js/palette
https://liquid-js.github.io/palette/
To obtain colours from an image, use extractImageData and quantize (note: quantize might take a long time to run depending on image size; consider running it asynchronously).
import { extractImageData, quantize } from '@liquid-js/palette'
const imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Peace_Of_Nature_%28129019177%29.jpeg/640px-Peace_Of_Nature_%28129019177%29.jpeg'
const img = new Image()
img.crossOrigin = 'anonymous'
img.addEventListener('load', () => {
const imageData = extractImageData(img)
const colors = quantize(imageData)
console.log(colors)
})
img.src = imageUrl