Image Color Picker - Hex Code & Palette From a Photo

Image

Pick HEX, RGB and HSL colors from a photo or screenshot, compare two, and get a palette with shares. The image is read in your browser, never uploaded.

Open an image

Pick a color

Choose the sample size

Read and compare

Colors are read from the file as your screen shows it, in sRGB. A photo’s colors depend on the light and the camera, so a pick is no match for a physical paint, ink or fabric.

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 = Σ(Opacity × Linear) ÷ Σ Opacity
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 = √(ΔL² + Δa² + Δb²)
Δ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 = (L1 + 0.05) ÷ (L2 + 0.05)
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

  1. 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.
  2. 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.
  3. 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.
  4. Björn Ottosson. A perceptual color space for image processing. December 23, 2020.
  5. 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.
  6. 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.
  7. 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

Help

Quick Start Guide

  1. Open an image: Choose a file, take a photo on a phone, paste one (Ctrl+V, or Command+V on a Mac), or drop it on the page. Three drawn samples, a flat poster, a fruit photo and an app screenshot, are there to try first.
  2. Pick a color: Tap or click a spot. The magnifier shows the pixels around it; on a phone it sits in the corner, clear of your finger. With a keyboard, the arrows move the point and Enter picks.
  3. Choose the sample size: 3 × 3 for photos, 1 px for flat graphics, up to 31 × 31 for a textured surface such as fabric or a wall.
  4. Read and compare: Choose a pick in the list to see its HEX, RGB, HSL, OKLCH and HSV codes, the nearest CSS name, and the contrast of white and black text on it. Tick two picks to see how far apart they are.
  5. Keep the colors: Name your picks, copy them as CSS variables or a Tailwind theme, or export them. Switch to Palette for the image’s main colors.

Frequently Asked Questions

Open the image here and tap or click the color. The pick shows its hex code with RGB and HSL, each with a copy button. For a logo or a screenshot choose 1 px, which reads one pixel exactly; for a photo keep 3 × 3, which averages nine.

Last updated