Menu

How to get the exact HEX code from any image (and turn it into a CSS or Tailwind palette)
πŸ“°

How to get the exact HEX code from any image (and turn it into a CSS or Tailwind palette)

DEV Community: cssΒ·Varinder Pal SinghΒ·8 days ago
#G13iEuwV
#devtocss#devto#dev#color#brand
Reading 0:00
15s threshold

Every front-end developer has been there: a designer sends a screenshot instead of a Figma file, a client wants "the blue from our logo", or you're rebuilding a site and nobody remembers the brand colors. You need exact color codes, and you need them fast.

Here's the workflow I use, plus a few traps that make "the color from the image" less obvious than it sounds.

Why the color you pick is often wrong

Photos are noisy. Two neighbouring pixels on a wall that looks flat can differ by several shades because of JPEG compression, lighting and sensor noise. If you click one random pixel, you get a color, not the color a person would describe.

Two fixes:

Average a small area. Sampling a 5Γ—5 block (25 pixels) and averaging gives a much steadier value than a single pixel.

Zoom before you click. Thin lines, text and logo edges are only a few pixels wide.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.