<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: An Hoang Gia</title>
    <description>The latest articles on DEV Community by An Hoang Gia (@an_hoanggia_eb7d48d9de74).</description>
    <link>https://dev.to/an_hoanggia_eb7d48d9de74</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4024522%2F5be96145-9efb-4a1b-92f6-fb623fac4e1a.jpg</url>
      <title>DEV Community: An Hoang Gia</title>
      <link>https://dev.to/an_hoanggia_eb7d48d9de74</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/an_hoanggia_eb7d48d9de74"/>
    <language>en</language>
    <item>
      <title>Turn any photo into a CSS color palette (image to HEX, RGB &amp; OKLCH)</title>
      <dc:creator>An Hoang Gia</dc:creator>
      <pubDate>Wed, 15 Jul 2026 16:11:34 +0000</pubDate>
      <link>https://dev.to/an_hoanggia_eb7d48d9de74/turn-any-photo-into-a-css-color-palette-image-to-hex-rgb-oklch-439l</link>
      <guid>https://dev.to/an_hoanggia_eb7d48d9de74/turn-any-photo-into-a-css-color-palette-image-to-hex-rgb-oklch-439l</guid>
      <description>&lt;p&gt;Designers hand you a mood photo — a sunset, a product shot, a piece of packaging — and say &lt;em&gt;"use these colors."&lt;/em&gt; No hex codes, no tokens, just a picture. Here's a repeatable way to turn that image into a proper, production-ready CSS palette in a couple of minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Pull the key colors out of the image
&lt;/h2&gt;

&lt;p&gt;Start by sampling the colors that actually carry the image. The quickest route is an &lt;a href="https://colorpicker.cx/color-picker" rel="noopener noreferrer"&gt;image color picker&lt;/a&gt;: drop in the photo, click the pixels you care about — a highlight, a mid-tone, a shadow, an accent — and copy each value. You'll get HEX, RGB, HSL, HSV and CMYK for every point, and because it runs client-side the image never leaves your browser.&lt;/p&gt;

&lt;p&gt;Aim for four or five anchor colors — highlight #F4E3C1, mid-tone #C9784B, shadow #3A2A21, accent #2E6E8E.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Grow it into a full, balanced palette
&lt;/h2&gt;

&lt;p&gt;Four hand-picked colors rarely make a complete UI palette — you need tints, shades and neutrals that sit together. Feed an anchor color into a &lt;a href="https://colorpicker.cx/palette" rel="noopener noreferrer"&gt;palette generator&lt;/a&gt; to expand it into a cohesive scheme, then export the whole set as CSS custom properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Normalize everything to OKLCH so scales stay even
&lt;/h2&gt;

&lt;p&gt;If you want tints and shades that step evenly, convert the anchors to OKLCH. Unlike HSL, OKLCH is perceptually uniform, so equal changes in lightness &lt;em&gt;look&lt;/em&gt; equal. Paste any value into a &lt;a href="https://colorpicker.cx/converter" rel="noopener noreferrer"&gt;color converter&lt;/a&gt; to get the OKLCH form: #c9784b becomes oklch(0.63 0.12 47). Now a hover or active state is a one-channel tweak — drop the lightness a touch and the hue stays put.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Check the pairings for contrast
&lt;/h2&gt;

&lt;p&gt;A palette that looks great can still fail on readability. Before you lock it in, run your text/background pairs through a &lt;a href="https://colorpicker.cx/contrast" rel="noopener noreferrer"&gt;contrast checker&lt;/a&gt; and aim for at least 4.5:1 for body text (WCAG AA). OKLCH makes fixes easy — nudge only the lightness value until the pair passes, without shifting the hue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The loop — sample from the image, expand into a palette, normalize to OKLCH, verify contrast — turns a single reference photo into a documented, accessible set of CSS tokens. All four steps live in one free, no-signup toolkit at &lt;a href="https://colorpicker.cx" rel="noopener noreferrer"&gt;colorpicker.cx&lt;/a&gt; if you'd rather keep them in one tab.&lt;/p&gt;

&lt;p&gt;What's your go-to for building palettes from a reference image? Curious how others approach it.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>design</category>
      <category>frontend</category>
    </item>
    <item>
      <title>How to Pick an Exact Color From an Image and Use It in CSS (HEX, RGB, HSL &amp; OKLCH)</title>
      <dc:creator>An Hoang Gia</dc:creator>
      <pubDate>Wed, 15 Jul 2026 12:45:06 +0000</pubDate>
      <link>https://dev.to/an_hoanggia_eb7d48d9de74/how-to-pick-an-exact-color-from-an-image-and-use-it-in-css-hex-rgb-hsl-oklch-fp5</link>
      <guid>https://dev.to/an_hoanggia_eb7d48d9de74/how-to-pick-an-exact-color-from-an-image-and-use-it-in-css-hex-rgb-hsl-oklch-fp5</guid>
      <description>&lt;p&gt;Sooner or later every front-end dev hits this: a client sends a screenshot, a photo, or a Figma export and says &lt;em&gt;"make the button this exact blue."&lt;/em&gt; You need the precise color value — not "close enough" — and you need it in a format CSS understands.&lt;/p&gt;

&lt;p&gt;Here's a quick, reliable workflow for grabbing colors from an image and turning them into production-ready CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Sample the pixel with an image color picker
&lt;/h2&gt;

&lt;p&gt;Browser devtools ship with an eyedropper, but it only samples what's already rendered on the page — not an arbitrary photo or a design mockup sitting in another tab.&lt;/p&gt;

&lt;p&gt;The fastest way is a dedicated &lt;a href="https://colorpicker.cx/color-picker" rel="noopener noreferrer"&gt;image color picker&lt;/a&gt;: drop in any JPG, PNG, WebP or SVG, click the pixel you care about, and you instantly get the value in every format at once — HEX, RGB, HSL, HSV and CMYK. It runs entirely in the browser, so the image never leaves your machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Picked pixel -&amp;gt; #2D7FF9
               rgb(45, 127, 249)
               hsl(216, 94%, 58%)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Drop that HEX straight into your stylesheet and you're done for the common case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2D7FF9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Convert it for modern CSS with OKLCH
&lt;/h2&gt;

&lt;p&gt;HEX is fine, but modern CSS has a better tool for &lt;em&gt;manipulating&lt;/em&gt; color: &lt;strong&gt;OKLCH&lt;/strong&gt;. It's perceptually uniform, which means lightening, darkening or building a consistent scale actually looks right to the human eye — unlike nudging HSL, where equal steps look uneven.&lt;/p&gt;

&lt;p&gt;Paste any value into a &lt;a href="https://colorpicker.cx/converter" rel="noopener noreferrer"&gt;color converter&lt;/a&gt; and you'll get the OKLCH equivalent (plus RGBA, HWB, and the nearest CSS named color):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#2D7FF9 -&amp;gt; oklch(0.63 0.19 258)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can build a hover/active scale by adjusting a single channel — lightness — and trust that each step is visually even:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;oklch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.63&lt;/span&gt; &lt;span class="m"&gt;0.19&lt;/span&gt; &lt;span class="m"&gt;258&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--brand-hover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;oklch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.58&lt;/span&gt; &lt;span class="m"&gt;0.19&lt;/span&gt; &lt;span class="m"&gt;258&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--brand-muted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;oklch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.85&lt;/span&gt; &lt;span class="m"&gt;0.06&lt;/span&gt; &lt;span class="m"&gt;258&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--brand&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.button&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--brand-hover&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because OKLCH separates lightness from hue and chroma, you can also fix a whole palette's contrast by only touching the &lt;code&gt;L&lt;/code&gt; value — no more eyeballing hex codes.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Check the contrast before you ship
&lt;/h2&gt;

&lt;p&gt;An exact color is only useful if people can read the text on it. Run your foreground/background pair through a &lt;a href="https://colorpicker.cx/contrast" rel="noopener noreferrer"&gt;WCAG contrast checker&lt;/a&gt; — aim for at least 4.5:1 for body text (AA) and note that APCA is the more accurate, polarity-aware method coming with future WCAG.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;#FDF0D5&lt;/code&gt; text on &lt;code&gt;#003049&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Contrast ratio: 12.25  -&amp;gt; passes AA &amp;amp; AAA
APCA: Lc 94            -&amp;gt; great for body text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The whole loop — &lt;strong&gt;pick from image, convert to OKLCH, verify contrast&lt;/strong&gt; — takes about thirty seconds and gets you color values you can actually trust. All three steps live in one free, no-signup toolkit at &lt;a href="https://colorpicker.cx" rel="noopener noreferrer"&gt;colorpicker.cx&lt;/a&gt; if you want them in one place.&lt;/p&gt;

&lt;p&gt;Are you reaching for OKLCH in production yet, or waiting for wider tooling? Curious to hear in the comments.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>a11y</category>
    </item>
    <item>
      <title>How to Get the Exact HEX Color From Any Image (3 Free Ways)</title>
      <dc:creator>An Hoang Gia</dc:creator>
      <pubDate>Fri, 10 Jul 2026 21:01:37 +0000</pubDate>
      <link>https://dev.to/an_hoanggia_eb7d48d9de74/how-to-get-the-exact-hex-color-from-any-image-3-free-ways-4e08</link>
      <guid>https://dev.to/an_hoanggia_eb7d48d9de74/how-to-get-the-exact-hex-color-from-any-image-3-free-ways-4e08</guid>
      <description>&lt;p&gt;Every frontend dev hits this at some point: a designer sends you a screenshot, a client sends a logo, and you need the &lt;em&gt;exact&lt;/em&gt; HEX value of a color in it. Here are three quick ways to grab it — no Photoshop required.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Browser DevTools (built-in eyedropper)
&lt;/h2&gt;

&lt;p&gt;Chrome and Edge have a hidden eyedropper inside DevTools:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open DevTools (&lt;code&gt;F12&lt;/code&gt;) and inspect any element with a &lt;code&gt;color&lt;/code&gt; or &lt;code&gt;background-color&lt;/code&gt; property&lt;/li&gt;
&lt;li&gt;Click the little color swatch in the Styles panel&lt;/li&gt;
&lt;li&gt;The eyedropper is now active — hover anywhere on the page and click&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Limitation:&lt;/strong&gt; it only works on colors inside the current page. If your color lives in a JPG someone sent you in Slack, you first have to open that image in a tab.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The EyeDropper API (do it in your own code)
&lt;/h2&gt;

&lt;p&gt;Modern Chromium browsers ship a native &lt;code&gt;EyeDropper&lt;/code&gt; API, so you can build color picking into your own tools:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;eyeDropper&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;EyeDropper&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;sRGBHex&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;eyeDropper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sRGBHex&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// e.g. "#7c3aed"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returns the color of any pixel on the screen — even outside the browser window. Support is still Chromium-only (no Firefox/Safari as of 2026), so feature-detect with &lt;code&gt;if ('EyeDropper' in window)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Upload the image to a color picker tool
&lt;/h2&gt;

&lt;p&gt;When you need more than one pixel — say, the full palette of a brand image — an image color picker is faster. I built &lt;a href="https://colorpicker.cx" rel="noopener noreferrer"&gt;ColorTools&lt;/a&gt; exactly for this workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;a href="https://colorpicker.cx/color-picker" rel="noopener noreferrer"&gt;colorpicker.cx/color-picker&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Drop in any image (it never leaves your browser — processing is client-side)&lt;/li&gt;
&lt;li&gt;Click any pixel to get HEX, RGB and HSL, or let it extract the dominant palette automatically&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From there you can jump straight into the &lt;a href="https://colorpicker.cx/contrast" rel="noopener noreferrer"&gt;contrast checker&lt;/a&gt; to verify WCAG AA/AAA compliance of the colors you just picked — handy when the "brand color" a client insists on is a 2.1:1 disaster on white.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: converting between formats
&lt;/h2&gt;

&lt;p&gt;Got the HEX but need HSL for your CSS custom properties? The conversion is one formula, but if you do it rarely, a &lt;a href="https://colorpicker.cx/converter" rel="noopener noreferrer"&gt;converter&lt;/a&gt; is quicker than remembering the math.&lt;/p&gt;




&lt;p&gt;What's your workflow for grabbing colors — DevTools, a desktop app, or something else? Curious what everyone uses in 2026.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
