Fully on-device: the image is decoded to a canvas, pixels are quantized into RGB buckets and ranked by coverage, then each dominant color is matched to its nearest Tailwind token and scored for WCAG 2.1 contrast against white and black. Nothing is uploaded, and the AA verdicts are computed rather than eyeballed.
The first version of this ranked colors by pixel count, which is the obvious approach and is wrong in a way that only shows up on real images. Feed it a product shot on white — the most common thing anyone tries — and you get white, four greys, and black, while the brand color that made the image worth sampling never appears. Two effects stack: the background owns most of the frame, and the accent is split across dozens of quantization buckets because every highlight and shadow of a glossy surface lands in a different one. An orange covering a tenth of the image loses to a grey covering a fiftieth. Clustering accents by hue re-unites the gradient, and ranking them apart from neutrals stops the background competing for slots it was never a candidate for. The contrast column is still the half that saves you money — brand palettes handed over in a style guide routinely fail AA for body text, and nobody notices until the audit.