Colour Picker From Image: HEX, RGB, HSL and a 5-Colour Palette
Open a picture, move over it and read the colour under the pointer as HEX, RGB and HSL, with a magnifier that shows the pixels around it.
Maintained by Hirantha Sandaruwan Lakshan. Updated 15 October 2026.
About this tool
Click or tap to keep a colour in your list, and copy any value with one button. One more button builds a five-colour palette from the whole picture. It all runs in your browser and the image is never uploaded.
How it works
The colour comes from the original picture, not from the scaled copy on screen. The picture is drawn smaller to fit the page, so the tool turns your pointer position into a pixel of the original: the pointer's distance across the canvas's on-screen box, as a fraction, times the picture's width and height. A fraction is the same whatever the screen's pixel density or the CSS scaling, so on a high-DPI display it still picks the pixel under the pointer. That one pixel is copied alone into a 1 by 1 canvas with smoothing off and read back with getImageData. The arrow keys move the crosshair a pixel at a time (10 with Shift), and Enter keeps the colour.
HEX is the three channels in base 16. HSL comes from the conversion code in CSS Color Level 4: hue in degrees from 0 to 360, saturation and lightness in percent. The values are shown rounded to whole numbers, so rgb(51, 102, 153) reads hsl(210, 50%, 40%). A test converts a grid of 140,608 colours and 20,000 random ones from RGB to HSL and back without rounding and gets every one back unchanged; typing the rounded HSL numbers back in can land a few units away on a channel. A swatch's label is black or white, whichever has the higher WCAG 2.2 contrast ratio against it.
The palette uses median cut, a classic colour-reduction method. The picture is first shrunk to at most 128 pixels on its long side. All its exact colours are counted and placed in one box. The tool then repeatedly takes the box with the most pixels times the widest colour range, sorts its colours along the channel with the widest range and cuts where the running pixel count reaches half. The cut never separates identical colours. When there are as many boxes as colours you asked for (3, 5 or 8), each box becomes the average of its pixels. There is no randomness, and where pixels sit does not matter, so the same picture always gives the same palette.
The eyedropper button uses the browser's EyeDropper API, which can read any pixel on your screen, even outside the page. MDN marks it as experimental with limited availability and secure-context only, and its compatibility data lists it in Chrome 95 and Chromium-based browsers such as Edge on a computer, but not in Firefox, Safari or Chrome for Android (checked on 2026-10-15). Where it is missing the button is replaced by a note, and picking from the image works everywhere. Colours are the sRGB values the browser shows, and MDN notes that fingerprinting protection can add tiny noise to pixels read from a canvas.
Worked examples
Reading one pixel: #336699
A pixel of rgb(51, 102, 153) is HEX #336699. In HSL the largest channel is blue, the lightness is (153 + 51) / 2 / 255 = 40%, the saturation is 50% and the hue is 210 degrees, so the tool shows hsl(210, 50%, 40%).
A palette from five flat blocks
A test picture has 100 red, 50 green, 25 blue, 15 white and 10 black pixels. The five-colour palette returns exactly those five colours, biggest first, with shares of 50%, 25%, 12.5%, 7.5% and 5%.
A grey ramp split in two
Take 256 greys from 0 to 255, one pixel each, and ask for two colours. The cut falls after the 128th pixel. The lower half (0 to 127) averages 63.5 and the upper half (128 to 255) averages 191.5, which round to #404040 and #C0C0C0.
The same colours in the three formats the tool shows
| Colour | HEX | RGB | HSL |
|---|---|---|---|
| Red | #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) |
| Green | #00FF00 | rgb(0, 255, 0) | hsl(120, 100%, 50%) |
| Blue | #0000FF | rgb(0, 0, 255) | hsl(240, 100%, 50%) |
| Orange | #FF8000 | rgb(255, 128, 0) | hsl(30, 100%, 50%) |
| Steel blue | #336699 | rgb(51, 102, 153) | hsl(210, 50%, 40%) |
| Mid grey | #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) |
Frequently asked questions
How do I get the HEX code of a colour in a photo?
Drop the photo on the page, hover over the spot you want and click it. The HEX code appears beside the picture and is added to your list, and the Copy button puts it on your clipboard. On a touch screen, tap the spot, then use the fine-tune buttons to move one pixel at a time.
Why is the colour slightly different from what I expected?
Three common reasons. JPEG compression blurs colour around edges, so pick from the middle of a flat area. A picture with an embedded colour profile can differ a little from what a photo editor reports, because the browser shows sRGB. And with fingerprinting protection on, browsers may add tiny noise to pixels read from a canvas, so a value can be off by one.
Does the screen eyedropper work in every browser?
No. The EyeDropper API is in Chrome and other Chromium browsers such as Edge on a computer. It is not in Firefox, Safari or Chrome for Android, and it only works on secure (https) pages. The button appears only where it is available. Picking colours from the image itself works everywhere.
How does the five-colour palette work?
It uses median cut on a small copy of the picture: all the exact colours go in one box, which is split in two at the median along its widest colour channel, again and again until there are five boxes, and each box is averaged. The shares show how much of the picture each colour stands for. You can ask for 3 or 8 colours instead.
Will I get the same palette every time?
Yes. There is no random step, and the result depends only on how many pixels of each colour there are. The same picture always gives the same palette, in the same order.
Does it work on a phone or with a keyboard?
Yes. Tap the picture to pick a colour, and use the Left, Up, Down and Right buttons to fine-tune by one pixel. With a keyboard, focus the picture, move with the arrow keys (Shift for 10 pixels), and press Enter to keep the colour. The magnifier shows an 11 by 11 block of pixels around the current one.
Can I pick from a transparent PNG?
Yes. If the pixel is partly see-through the page says how opaque it is. The HEX, RGB and HSL values show the colour itself and ignore the transparency. A fully transparent pixel has no meaningful colour and usually reads as black.
Is my image uploaded anywhere?
No. The picture is decoded and read inside your browser tab and never sent over the network.
Sources & references
Updated Oct 15, 2026