Formulas and sources
Each formula this calculator uses, where it comes from, and what it leaves out. "How it works" shows the same formula with your own numbers.
A pick’s color
- Average
- the pick, each channel, in linear light
- Linear
- a pixel’s channel in linear light
- Opacity
- the pixel’s opacity, 0 to 1
Each pixel’s red, green and blue are taken from sRGB to linear light, averaged over the sample (1, 9, 25, 121 or 961 pixels) weighted by opacity, and encoded back to sRGB. Pixels outside the image or fully transparent are left out. A wide-gamut pick is read again in Display P3 to tell whether its hex was clipped.
Source: The sRGB encoding from [1], its linear-light form and Display P3 from [2]. The averaging in linear light is this page’s choice, stated here.
The difference of two colors
- ΔE OK
- the distance between two colors in Oklab
L, a and b are the two colors’ Oklab values. Under 0.02 they are the same to the eye; very close under 0.05 and close under 0.1 are this page’s bands. The palette merges colors closer than 0.03, and gives the nearest CSS name by the same distance.
Source: Oklab from [3] and [4]; ΔE OK and one just-noticeable difference of 0.02 from [5]. The HSL codes follow [6].
Text on the color
- Contrast
- the contrast of text on the color
L1 and L2 are the relative luminances of the lighter and the darker color, here the pick against white and against black. The ratio is cut, never rounded up, to two places.
Source: The ratio and its thresholds from [7].
Sources
- International Electrotechnical Commission (IEC). IEC 61966-2-1:1999, Multimedia systems and equipment, Colour measurement and management, Part 2-1: Colour management, Default RGB colour space, sRGB. Edition 1.0, October 18, 1999.
- World Wide Web Consortium (W3C). CSS Color Module Level 4, sections 10.3, srgb-linear, and 10.4, display-p3; section 19, Sample code for Color Conversions. Candidate Recommendation Draft, November 12, 2026; a draft that may change.
- World Wide Web Consortium (W3C). CSS Color Module Level 4, section 9, Oklab and OkLCh; section 13.3, Color Space for Interpolation; section 6.1, Named Colors. Candidate Recommendation Draft, November 12, 2026; a draft that may change.
- Björn Ottosson. A perceptual color space for image processing. December 23, 2020.
- World Wide Web Consortium (W3C). CSS Color Module Level 4, section 20.3, ΔEOK; section 14.2.1, where one just-noticeable difference is 0.02. Candidate Recommendation Draft, November 12, 2026; a draft that may change.
- World Wide Web Consortium (W3C). CSS Color Module Level 4, section 7.2, Converting sRGB Colors to HSL. Candidate Recommendation Draft, November 12, 2026; a draft that may change.
- World Wide Web Consortium (W3C). Understanding Success Criterion 1.4.3: Contrast (Minimum), the success criterion, its notes on large-scale text and on rounding; with 1.4.6 and 1.4.11. Understanding WCAG 2.2, read November 15, 2026.
What this calculator does not cover
- Paint, ink and fabric: a photo’s color depends on the light and the camera, so it is no Pantone, RAL or paint match.
- Color profiles: colors are read in sRGB, as the screen shows the file; a Display P3 pick is flagged when clipped in Chrome, Edge and Safari, which can read P3.
- Very large images: past a browser’s canvas limit (16.7 megapixels on an iPhone) the image is read smaller, and the page says so.
- Animated images: only the first frame is read.
- Privacy settings: some browsers add a slight noise to what a page reads from an image; the page says when yours does.
Sources checked on
How we choose sources and test the calculators: How CalcTrail calculates