Image Color Picker: Read the Exact HEX, RGB and HSL Value of Any Pixel

An image color picker answers one narrow question: what color is this particular pixel? You have a photograph, a screenshot, a logo file or a product shot, and you need the value behind it, not a close match chosen by eye. This page walks through how the tool on this site works, what each of its nine notations means, how the dominant palette is built, and where the limits of sampling a picture in a browser actually sit.

The tool is a single page. You load one image, move the magnifier, and read the value in HEX, RGB, RGBA, HSL, HSV, CMYK, OKLCH, LAB and XYZ. Nothing is uploaded, no account is needed, and the picked colors stay available in a history of the last fifty entries. Everything below explains the behaviour you will see, including the parts that surprise people on the first run.

What this image color picker does

The subject here is our own tool, so start with the exact scope. It reads colors from an image file that you supply. It does not sample your screen by default, it does not open a URL from the web, and it does not edit the picture. One file per load, up to 40 MB, with .png, .jpg, .jpeg, .webp, .gif, .bmp and .svg accepted.

The reading is pixel exact. The image is drawn onto a canvas at its own pixel dimensions, and every value you see comes from the red, green, blue and alpha numbers stored for that cell. That is a different job from a color wheel, which asks you to describe a color, and a different job from a palette generator, which invents colors from one anchor. Here the color already exists inside the file and the tool recovers it.

Three things follow from that design. First, the answer is objective: the same file gives the same numbers on any machine. Second, the answer is only as good as the source: a compressed JPEG contains blended pixels, and the tool will honestly report the blend. Third, privacy is structural rather than a promise, because a local file drawn onto a local canvas has no network step to intercept.

What the page also does is turn one sample into a decision. Alongside the nine notations it prints the WCAG contrast ratio of the color against white and against black, and it extracts a palette of four to twelve dominant colors from the whole image, which you can copy as CSS variables, a Tailwind snippet, JSON tokens or a comma separated hex list.

How a browser reads the color of a pixel

A local file is read as a data URL, turned into an image element, and drawn onto a canvas sized to the image's natural width and height. From there the Canvas 2D method getImageData returns an ImageData object holding the raw channels. For an 8 bit canvas each channel is an integer from 0 to 255, in RGBA order, four entries per pixel. One sample therefore costs one small read, which is why the readout can follow the cursor without lag.

Two details in that chain matter more than they look.

The first is coordinate space. The image on screen is responsive, so a cursor position is a display coordinate, while getImageData wants a coordinate in the image's own pixel grid. The tool multiplies the cursor offset by the ratio between the natural size and the rendered size before reading, and it accounts for the one pixel border of the canvas element. Without that correction the sample drifts by a pixel or two near the right and bottom edges, which is exactly where logos and UI screenshots put thin details.

The second is canvas security. A canvas that has drawn an image from another origin without CORS permission is tainted, and reading its pixels throws a SecurityError. Because this tool only ever draws files the user selected, the canvas stays clean, but the read is still wrapped so a browser specific failure surfaces as a message instead of a broken page. The same rule is why a picker that loads arbitrary image URLs needs CORS headers on the image host.

There is one more browser behaviour worth knowing because it is invisible until it bites. When fingerprinting protection is active, browsers may add subtle random noise to the data returned by getImageData, so that reading and writing pixels does not perfectly round trip. The values you copy are still the values of the pixel you sampled, but a script that compares two reads of the same cell may see a difference of one step. For design work that is irrelevant; for pixel diffing it is not.

Canvas size limits that shape the grid

The working canvas is capped at 4096 pixels on the longest side. That number is not arbitrary: mobile Safari limits canvas dimensions to 4096 by 4096, and exceeding the limit makes drawing commands fail silently. A 6000 pixel photo is therefore scaled down proportionally, with a toast that says so, and the pixel grid you sample afterwards is the reduced one.

Single pixel or averaged block

The sample mode selector offers three settings, and the choice changes the answer more than most people expect. In 1 px mode the tool returns exactly the channel values of the pixel under the cursor. In 3x3 and 5x5 mode it reads a square block centred on the cursor, sums the channels and divides by the number of pixels, so the result is the average color of that block.

Why average at all? Because most real images are not made of flat areas. JPEG compression stores color in blocks and reconstructs them approximately, so a supposedly uniform background carries low amplitude noise that shifts a channel by a few steps from pixel to pixel. Anti-aliasing does the same thing at every edge: the border pixel of a logo is a blend of the logo color and whatever sits behind it. Sampling one pixel inside a large flat region gives the true fill; sampling one pixel on a border gives a color that exists nowhere in the design.

The practical rule is simple. Use 1 px when you need the exact stored value of a specific cell, for example to prove which of two nearly identical hex codes a file actually contains. Use 3x3 for logos, icons and screenshots, where it removes edge blending without smearing a two color boundary too far. Use 5x5 on gradients, textured surfaces and photographs, where the interesting answer is the local average rather than a single noisy sample.

The magnifier helps you aim. Its zoom runs from 4x to 20x, and image smoothing is disabled inside it, so you see the real pixel blocks rather than a blurred interpolation. Crosshairs mark the cell being read, and the centre of the loupe is left clear so the indicator never covers the color you are inspecting. Keyboard users can step one pixel at a time with the arrow keys and press Enter to commit a color, which is often faster than chasing a cursor over a 4000 pixel wide photo.

Sampling colors outside the loaded image

For colors outside the loaded image there is a second path. The Screen eyedropper button uses the browser's own EyeDropper API, which returns an sRGB hex value for any pixel on the display. It is available over HTTPS in Chromium based browsers and is still listed as limited availability, so the button is disabled in Firefox and Safari. That API samples the screen, not the file, and it cannot read pixels from a different window on some platforms, which is a system level restriction rather than a bug in the page.

Nine color notations and when to use each

Every pick produces nine strings from the same three channel values. That is not decoration: each notation exists because a different tool or a different question needs it. The table below uses one color, #3A7BD5, to show what the same pixel looks like in each form.

Notation Value for the same pixel Where it is used
HEX #3A7BD5 CSS, design files, brand guides
RGB rgb(58, 123, 213) canvas and JavaScript color strings
RGBA rgba(58, 123, 213, 1) overlays and transparency work
HSL hsl(215, 64.9%, 53.1%) adjusting a hue or lightness by hand
HSV hsv(215, 72.8%, 83.5%) pickers and graphics tools that model value
CMYK cmyk(73%, 42%, 0%, 16%) rough print reference only
OKLCH oklch(0.586 0.1533 257.2) perceptually even steps in modern CSS
LAB lab(51.69 9.73 -52.29) color difference and device independent work
XYZ xyz(20.84 19.87 65.69) the reference space behind the others

HEX is the notation most teams exchange, and it is exact for opaque colors. RGB and RGBA are what canvas and JavaScript expect, and RGBA is the only one of the nine that can express partial transparency directly. HSL is easier to reason about than RGB when you want a lighter or duller variant, because lightness and saturation are separate numbers, and HSV is the model behind many pickers.

CMYK, OKLCH and the CIE spaces

The last three are the interesting ones. CMYK printed by a browser is a mathematical conversion of an sRGB value, with no ink, paper or press profile involved, so it is a starting point for a conversation with a print shop and nothing more. OKLCH comes from CSS Color 4, which also defines lab, lch, oklab and the color() function with spaces such as display-p3, a98-rgb, prophoto-rgb, rec2020 and XYZ. Oklab was designed so that equal numeric steps look like equal perceptual steps, which is why modern design systems use it for generating tints and shades that stay visually even. LAB and XYZ are the classic CIE spaces: XYZ is the reference model that other spaces convert through, and LAB packs it into lightness plus two opponent axes.

A note on precision. Conversions between spaces are computed from the same integer sRGB triple, so the strings agree with each other. Rounded values may differ in the last digit from a desktop application that works in floating point from a wider source gamut, and that is expected rather than a mismatch.

Getting a dominant palette out of a photo

A single pixel answers a narrow question. When you are choosing a background, a section tint or a theme, the useful question is what colors the image is made of overall, and that is what the palette card computes. The count selector offers 4, 6, 8, 10 or 12 swatches, and the first swatch is the color that covers the largest share of the picture.

Under the hood the image is reduced to a sample of pixels and grouped into clusters. The classic approach is median cut quantization, the algorithm family behind MMCQ, which recursively splits the color volume along its widest axis until the requested number of boxes exists. The alternative is k-means, which iteratively moves cluster centres until they stabilise; it is usually slower on large images and can land in different local minima depending on the starting points. Libraries such as Color Thief ship MMCQ variants, which is a good sign that the approach balances quality against speed on ordinary photographs.

Two implementation choices shape the result more than the algorithm name. Sampling every tenth pixel instead of all of them keeps a 12 megapixel photo responsive in the tab, and ignoring near transparent pixels stops a PNG with a transparent border from contributing a meaningless cluster. Ranking by pixel count then produces the ordering users expect: sky first in a landscape, the flat background first in a product shot, the dominant garment first in a portrait.

The export row turns the palette into something a project can consume. CSS variables come out as custom properties, ready for a stylesheet or a token file. The Tailwind option writes the colors as a config object. JSON gives an array of objects with hex, rgb and hsl for every swatch, which a script or a theme loader can read directly. The hex list is the plainest form, one comma separated string for pasting into a chat or a ticket.

A palette is a starting point, not a verdict. Dominant colors describe what is in the picture, and pictures often contain colors that are terrible as backgrounds. Use the palette to find candidates, then sample the specific pixels you intend to use and check their contrast before committing.

Checking contrast before the color ships

Every picked color shows its WCAG contrast ratio against white and against black, with an AA or AAA badge where the ratio qualifies. This is the part of the workflow most often skipped, and it is the part that decides whether text placed on the color is readable.

The thresholds come from WCAG 2.2. Success criterion 1.4.3, Contrast (Minimum), asks for 4.5:1 for normal text and 3:1 for large text at level AA. Criterion 1.4.6, Contrast (Enhanced), asks for 7:1 for normal text and 4.5:1 for large text at level AAA. Criterion 1.4.11 adds a 3:1 requirement for user interface components and graphical objects against adjacent colors. Large text is defined as roughly 18.66 pixels bold or 24 pixels regular, so a heading can pass where a paragraph fails on the same background.

Concrete numbers make the rule easier to hold. Take #3A7BD5 from the table: against white it measures 4.22:1, which misses the 4.5:1 AA line for normal text but clears the 3:1 bar for large text and for interface borders. Against black the same color measures 4.97:1, so dark text on it fails while white text on it also fails, which is the awkward middle that catches a lot of blue buttons. A bright yellow such as #F5C518 measures 1.63:1 against white and 12.88:1 against black, so it needs dark text and will never support white text. A near black like #1E1E1E sits at 16.67:1 against white, comfortably AAA.

Two habits follow. Sample the actual background pixel rather than trusting the brand guide, because gradients and photos shift the value under a button. Then check both directions, since the ratio is symmetric but the pass thresholds are not, and a color can be usable for text in one direction only.

Limits, format support and browser behaviour

Knowing the edges of the tool saves a support thread later.

Formats. PNG, JPG, JPEG, WebP, GIF, BMP and SVG are accepted, six formats across seven extensions. What the browser can decode, the canvas can sample, so a format the browser does not support fails at load rather than producing wrong values. Animated GIF is read as its first frame, because a canvas holds one frame at a time.

Size. Files above 40 MB are rejected outright, and the working canvas is capped at 4096 pixels on the long side. A larger image is scaled down and the toast says so. The cap is a mobile constraint, not a policy: exceeding a canvas dimension limit makes drawing commands fail without an error on some devices.

Transparency. The readout includes an alpha channel in the RGBA string, and the palette ignores near transparent pixels so they do not skew the clusters. A transparent PNG can still carry color data in its fully transparent pixels, so a sample taken there reports the stored RGB rather than the color you see against the page background.

Screen sampling. The EyeDropper API is Chromium only for now and requires a secure context. It reads the display, not the file, so it is the right tool for matching something in another application and the wrong tool for auditing a specific image.

What the page does not do: it does not write a new image, does not watermark, does not batch process, does not export CMYK or PDF, and does not upload anything. The history holds fifty colors in localStorage, which means it survives a reload on the same browser and disappears with site data.

Worked example: rebuild a logo palette step by step

Suppose a client sends a logo as a 2400 pixel wide PNG and asks for the brand colors as code. Here is the sequence this tool supports.

Load the file. It fits under the canvas cap, so no scaling happens. Move the magnifier over the largest flat area of the mark, switch to 3x3 to flatten any edge blending, and press Enter. The readout shows the fill as HEX plus the other eight notations. Copy the HEX.

Repeat for the accent shape and for the wordmark. Each press adds the color to the history, so after five or six picks the working set is visible without resampling. If the logo has a gradient, use 5x5 at two ends of the gradient to record the range rather than a single midpoint.

Now open the palette card and set the count to six. The swatches rank the picture by coverage, which usually surfaces the background, the main mark, the accent and the antialiased halos around them. Compare the palette against your manual picks: a color that appears in the palette but not in your list is often a real part of the artwork that the eye skipped.

Check contrast for each candidate against white and against black. Take the numbers from the badges rather than estimating: a mid blue that looks fine on a monitor can sit at 4.22:1 and fail AA for body text, as the earlier example shows. Decide per use: the primary color for large headings and borders, a darker variant for text, a lighter tint for surfaces.

Export. Copy CSS variables for a stylesheet, or the Tailwind snippet if the project uses utility classes, or JSON if a theme loader consumes tokens. Paste the hex list into the ticket so the values are searchable later.

Finally, note what the tool cannot tell you. It reports the colors in the file, not the colors the designer intended, and it reports them in sRGB. If the brand guide specifies Pantone or a print profile, the digital values are a translation that someone has to own.

Frequently Asked Questions

Why does the color change when I move the cursor one pixel?

Because neighbouring pixels genuinely differ. Compression noise, anti-aliasing and gradients all shift values between adjacent cells, so a one pixel move can change a channel by several steps. Switch to 3x3 or 5x5 sampling to get a local average instead of a single cell.

Can I pick a color from a web page or another application?

Yes, with the Screen eyedropper in a Chromium browser over HTTPS. It samples the display rather than a file. In Firefox and Safari the button is disabled, and the fallback is to take a screenshot, load it into the page and sample the pixel.

Does the tool work offline?

Once the page is loaded, sampling and palette extraction run entirely in the tab, so nothing depends on a network call. Opening the page the first time still needs a connection.

Are the CMYK values safe to send to a printer?

They are a formula applied to the sRGB pixel, not a profile based separation. Use them as a starting reference, and let the print shop convert the final artwork with the profile of the actual press and paper.

Why is my 8000 pixel photo shown smaller?

The working canvas is capped at 4096 pixels on the longest side because mobile browsers fail above that. The image is scaled down proportionally and a toast reports it. Colors are unaffected; only the addressable grid is coarser.

How accurate is the dominant palette?

It reflects pixel coverage, not visual importance. A large flat background will outrank a small logo, which is correct for backgrounds and misleading for brand extraction. Sample specific pixels when you need a particular element, and treat the palette as a shortcut for finding candidates.

What happens to the image I load?

It is read as a data URL, drawn on a canvas in the tab and never sent to a server. Reloading the page clears the image, and the pick history lives in localStorage until you clear site data.

Can I use the extracted colors in a commercial project?

Yes. The tool measures colors that already exist in your file and does not add or license anything. Check the rights to the source image itself, and check contrast before shipping.

mevaka
mevaka

Macedonia · SO reputation 2000 · Badges: 2🥇18🥈26🥉 · SO member since 2013