A HEX code taken from a photo is exact only about that file. It records the light that reached the camera, as altered by white balance, tone processing, compression and a colour-space conversion, so the same jacket can give #B85C38 in one picture and a visibly different code in the next. To get a value you can rely on, sample an averaged patch of a matte, evenly lit area, read it in sRGB and keep the source photo with it. When the physical colour of the object matters, measure the object instead.
Why does the same object give different HEX codes?
A camera records the light leaving a surface, not the surface. Change the light or the processing and every channel moves, even though the jacket did not change. The differences stack up in a fixed order, from the scene to the file you sample.
| Cause | What it does to the numbers | How to control it |
|---|---|---|
| Light source | A warm lamp pushes red up and blue down; open shade and overcast skies do the reverse | Shoot by daylight near a window, with no mixed sources |
| White balance | The camera guesses the light's colour on every shot and neutralises it, sometimes wrongly | Compare shots taken seconds apart; trust the one where a white or grey object reads neutral |
| Exposure and tone | Brightness and the tone curve change lightness and saturation; HDR merging adjusts regions separately | Avoid frames where the colour sits in deep shadow or near a clipped highlight |
| Highlights | A shiny spot reflects the light source, so it reads near white, not the object's colour | Sample a matte part of the surface |
| Compression | JPEG's DCT coding works on 8 × 8 blocks of samples and is lossy by design, so edges and fine texture shift | Sample the original, not a screenshot or a forwarded copy |
| Colour space | A wide-gamut original converted to sRGB loses its most saturated colours; a profile ignored on the way gives different numbers entirely | Read values in sRGB and keep the profile attached |
The last row is the easiest to miss. Apple's capture framework enables wide-gamut capture by default on supported devices, recording in a P3 colour space, while almost every HEX code you will paste anywhere is read as sRGB.
HEX, rgb() and hsl() are one colour in three notations
HEX is shorthand, not a separate colour model. The CSS Color Module Level 4 defines #RRGGBB as three pairs of hexadecimal digits for red, green and blue, and states that hex colours, like hsl() colours, resolve to sRGB. Each pair runs from 00 to FF, 0 to 255, so the format addresses 16,777,216 colours and nothing outside the sRGB gamut.
Display P3 needs its own notation. Apple's Display P3 uses the DCI P3 primaries, a D65 white point and the sRGB transfer function, so the same visible colour has different numbers in each space. Converting one rust through the CSS Color 4 matrices shows how far apart those numbers are.
| Written as | Value | What reads it correctly |
|---|---|---|
| HEX (sRGB) | #B85C38 | CSS, design tools, most pickers |
| rgb() (sRGB) | rgb(184 92 56) | The same colour in decimal |
| hsl() (sRGB) | hsl(17 53% 47%) | The same colour as hue, saturation and lightness |
| Display P3 | color(display-p3 0.675 0.380 0.253) | Wide-gamut aware browsers and apps |
| P3 values misread as sRGB | #AC6140 | Nothing; this is the error, a darker and duller rust |
That last row is what you get when a P3 photo loses its profile, or a picker reports P3 bytes and you paste them into a stylesheet. The colour did not change; the label on the numbers did.
Where should you sample, and how large an area?
The goal is a value that a second sample of the same surface would repeat. A single pixel will not do that, because neighbouring pixels differ through sensor noise, texture and compression. Apple's Digital Color Meter on the Mac is a useful model of the right behaviour: when more than one pixel falls inside its aperture it averages all of them, and the values it shows are specific to the colour space you choose.
- Start from the original capture. iPhones from the iPhone 7 on save HEIF under the High Efficiency setting and JPEG under Most Compatible (Settings, Camera, Formats); Apple notes that imports to a computer might be converted unless Keep Originals is on.
- Find a matte, evenly lit part of the surface, away from shine, edges and shadow.
- Sample an area, not a point: a patch a few dozen pixels across on a full-resolution photo.
- Take three samples from different spots on the same surface and compare them. If they disagree in the first digit of any pair, the lighting or the surface itself varies across that area.
- Read the values in sRGB if they are going into CSS or a design file, and write the colour space next to the code.
- Repeat on a second photo taken in different light. Agreement means you are close to the surface colour; disagreement means each photo only describes its own light.
Is your picker reading sRGB or the display's own values?
A picker that reads pixels off the screen, rather than out of the file, reports whatever space you ask it for. On a wide-gamut Mac display, "native" values are close to Display P3, so an sRGB pure red, #FF0000, shows up as roughly 234, 51, 35 by the CSS Color 4 conversion: the same red, re-expressed in a larger space. Copy those numbers into CSS as #EA3323 and you have changed the colour.
Files without any colour information have a default. The original sRGB proposal from HP and Microsoft put it plainly: an image with no ICC profile is assumed to be sRGB. That default protects untagged web images, and it is exactly what goes wrong when a P3 image is stripped of its profile and then sampled.
Two habits prevent most of this. Set screen pickers to sRGB before copying values meant for the web, and prefer tools that read the file's own pixels and honour its embedded profile.
When does "exact" matter, and what should you use then?
A photo-sampled HEX code is the right tool for screen work that only has to feel like the photo. It is the wrong tool whenever the colour has to match a physical object or a defined standard.
| You need | Is a HEX code from a photo enough? | Use instead |
|---|---|---|
| A web or app colour inspired by a photo | Yes | An averaged sRGB sample from the original |
| Your brand's defined colour | No | The values in the brand guidelines |
| Paint that matches a wall or object | No | A physical chip or the object, measured or matched at the paint counter |
| Fabric or thread | No | The maker's physical swatch card, compared in daylight |
| Print that matches a screen proof | No | A printed proof from the actual printer and paper |
| A product shot that matches the product page | Mostly | Sample the edited master file, in sRGB, after colour correction |
The pattern is simple. A HEX code can carry a photo's colour from one screen to another; it cannot carry an object's colour from the world to a screen and back.
How Tinta reads the values
Tinta does not sample a point you tap. It reduces the whole photo to at most 72 pixels on the long edge, so for a 12-megapixel photo (4032 × 3024) each of those 72 × 54 pixels stands in for a block of roughly 56 × 56 original pixels. That is the "sample an area" rule applied to the entire frame: noise, grain and compression artefacts average out before anything is measured. It then weights pixels toward the subject, groups them with median cut and reports each group's weighted average as an uppercase #RRGGBB value in 8-bit sRGB. How that pipeline chooses six colours is laid out in how Tinta derives exact HEX values from a photo.
The same design sets its limits. You cannot point Tinta at one precise spot, so a small detail can merge into a larger cluster. A cluster that spans light and shadow, or warm and cool light, comes back as one value in between. And because the values are sRGB, a very saturated colour from a P3 photo is clipped to fit inside sRGB. Tinta is free to use, with a Pro subscription for extra mount styles and larger exports.
What the HEX values become next is a separate decision: building a usable palette from those colours covers roles and contrast, and exporting the palette as a PNG or P3 image covers files.
A checklist before you hand over a HEX code
Run these checks before a sampled value goes into a stylesheet, a brief or a message to someone who will reproduce it.
- Source: the code came from the original file, not a screenshot, a social repost or a chat forward.
- Area: it is an average over a matte patch, not a single pixel or a highlight.
- Space: it is written as sRGB, with the space named next to the code.
- Repeatability: three samples of the same surface agree, and ideally a second photo does too.
- Destination: the colour stays on screens. If it is heading for paint, fabric or print, the HEX code is a reference for the conversation, and the physical sample decides.