Back to Blog

Half the Picture Was Sky

November 18, 2026
Share:
Half the Picture Was Sky

The sample picture on the new palette page is a flat little beach: an orange sky, a yellow sun, a red sail, two bands of sea and a strip of sand. Drop it in and the first swatch is #f6a07a at 49.7 percent. Half the picture was sky.

Then sand at 20 percent, the sea at 16.7, the deep water at 8.3, the sun at 3.7 and the sail at 1.6. Six colors, the biggest first, and every one of them is the exact hex I painted into the sample.

That page is Color Palette From Image. You drop a photo, pick a file or paste a screenshot, and you get its main colors as hex, CSS variables, Tailwind, JSON, a PNG sheet or an .ase swatch file. The picture never leaves the tab.

The upload comes first

Pulling a palette out of a picture is an old trick. The usual pages want the file uploaded before they'll show you a single swatch. The best-known palette app puts the export behind a subscription. One App Store review of it says this, and that's the mood:

Price gouging at its finest... this subscription model is absolutely ridiculous and exploitative

None of the work needs a server. A browser can draw a picture onto a canvas and read every pixel back. Counting colors in a few thousand pixels is a loop. Sending the photo away for that is a habit left over from a time when browsers couldn't do it.

So the page does it all in the tab. The file gets decoded right there and counted right there, and nothing goes back to a server.


Rank 19 of 1,754

I keep a ranked queue of free tool ideas. It has 1,754 of them. This one was nineteenth, score 9.25, with an estimate of about ten hours of work.

The card for it was short. Drop a photo or paste a screenshot. Get the dominant colors as hex, CSS variables and a Tailwind block. Let the person choose 2 to 12 colors. Export JSON, ASE and a PNG swatch sheet too. And never use the word Pantone, because that's somebody else's trademarked matching system and this page doesn't do matching.

The color pile on that list is long. A contrast checker and a color format converter already shipped from it. When I wrote up the converter, the palette tool was "sitting further down." Now it isn't.


8,723 upvotes for an old idea

The strongest number on the card is a Reddit post on r/InternetIsBeautiful. Its title says what the site did:

Enter a url to a picture and this website will generate a color palette based on the picture's composition.

It got 8,723 upvotes. That's the highest score for a useful tool in the whole design and color group of the research, and it's years old. People liked the idea a lot.

So the idea doesn't need inventing. What it needed was the same tool without the upload and without the toll on the export button.


Paste is how screenshots travel

The research notes said none of those pages supported Cmd+V. A lot of screenshots never get saved as a file. You grab a piece of the screen, it lands on the clipboard, and you paste it into chat.

On this page you can do the same. Click anywhere on the page and press Ctrl+V, or Cmd+V on a Mac. The page looks for an image in the clipboard and reads it like a dropped file. If the clipboard has text, the paste goes wherever it normally would.

Drop works, and so does Choose a picture. PNG, JPEG, WebP and GIF open in any browser. iPhone HEIC files go through the same decoder the HEIC to JPG page uses. The cap is 40 MB. A PDF gets turned away by its first bytes with a note to take a screenshot instead, because a PDF isn't a picture until something renders it.


Shrink it to 160 pixels

A phone photo has millions of pixels. You don't need millions of pixels to know the sky is orange.

So the first step draws the picture onto a small canvas with its long side at 160 pixels. A 4:3 photo becomes 160 by 120, which is 19,200 pixels. A tall phone screenshot becomes 90 by 160. A picture that's already smaller than that stays the size it is.

That one decision keeps the counting quick on any laptop or phone and doesn't change the answer much, because a palette is about big areas.

Pixels with an alpha under 128 get skipped. A logo on a transparent background gives you the logo's colors, not a giant swatch of black that was never there. If every pixel is see-through, the page says there's no color to pick.


32,768 buckets before any math

The next step is a histogram. Each pixel's red, green and blue get cut to 32 levels each, so there are 32 times 32 times 32 buckets, 32,768 in all. Each pixel falls into one.

The trick is what a bucket remembers: the running sum of the real pixels that fell in it, and how many there were. So a flat area of #f6a07a lands in one bucket, and that bucket's average is still exactly #f6a07a.

That's why the sample's swatches come back as the hexes I painted, and not as a near miss one step off. It's also why a big photo shrinks to a few thousand buckets at most. Everything after this works on buckets with weights, not on pixels.


Grouping by what the eye sees

Now the buckets get grouped into the number of colors you asked for. The grouping is k-means, the plainest clustering there is: pick some centers, give every bucket to its nearest center, move each center to the weighted middle of its group, repeat until nothing moves.

What matters is where "nearest" gets measured. In plain RGB, a step in green looks much bigger to the eye than the same step in blue. So the distance happens in OKLab, a color space where a step in any direction is about the same step to the eye. The math converts each bucket's average into OKLab once, groups there, and turns each center back into a hex at the end.

StepWhat it works onSize for a 4:3 photo
Shrinkpixels19,200
Histogrambuckets with weightsat most 19,200, usually far fewer
Group in OKLabbuckets2 to 12 centers
Sortcentersbiggest share first

The percent next to each swatch is that group's share of the pixels that weren't see-through. The list is sorted by it, so the biggest color always comes first.


Same picture, same palette

Most k-means code starts from random centers. That gives a slightly different palette each time you run it, which is fine for a paper and bad for a tool. Drop the same logo twice and you'd get two different answers.

So the start here is fixed. The first center is the heaviest bucket. Each next center is the bucket farthest from all the centers so far, nudged toward buckets that cover more of the picture. Far colors get a chance to be their own swatch, which is how a red sail at 1.6 percent survives next to a sky at 49.7.

There's a test for it. A 64 by 64 block of made-up colors gets grouped twice into eight, and both answers have to match exactly. Another test feeds 100 pixels of one blue, 300 of a yellow and 600 of an orange, and checks the shares come out as 0.6, 0.3 and 0.1 in that order.


When the picture runs out of colors

Ask for 12 colors from a logo that has three, and a lot of tools hand you 12 anyway. The extra nine are shades of the same three, invented to fill the slots.

This page gives you three. The status line says "3 colors. The picture has no more than that." There's a test for this one too: two flat colors, a request for 12, and the answer must have length 2.

Going the other way works too. Ask the sample for two colors and the beach splits into a warm half and a cool half:

CountWhat comes back
2#f4af84 at 75 percent, #2a738f at 25 percent
3the warm half, then the sea and the deep water apart
6all six painted colors, exact
12still six, because the sample has only six

The slider goes from 2 to 12 and starts at 6. Moving it regroups the same pixels right away.


Five ways to paste it somewhere

A palette on screen is only halfway there. It has to land in a stylesheet or a design file. The export box has five text formats, each with Copy and Download:

  1. Hex list, one per line.
  2. CSS variables on :root, named --palette-1 and up.
  3. Tailwind v4, an @theme block with --color-palette-1, so bg-palette-1 works in markup.
  4. Tailwind v3, a tailwind.config.js with a palette color object.
  5. JSON with the name, the hex, the RGB numbers and the percent.

Every swatch row also has its own Copy for a single hex. And there are two files: a PNG sheet, 1200 by 630, with one stripe per color and its hex printed on it in near-black or white, whichever reads better on that stripe, and an .ase file.


The .ase file is 264 bytes

ASE is Adobe Swatch Exchange, the swatch file the Adobe design apps import. It's an old binary format and it's small enough to write by hand.

The file starts with the four letters ASEF, a version of 1.0 and a count of blocks. Then each color is one block: a type, a length, the name in UTF-16 with a closing zero, the four bytes "RGB ", three float numbers between 0 and 1, and a flag that says it's a normal color. The name is the hex itself.

For the sample's six colors that's a 12 byte header plus six blocks of 42 bytes. 264 bytes for a whole palette. The test reads one back field by field: the magic letters, the version, the name "#f6a07a", the floats 246/255, 160/255 and 122/255, and the flag.

No library for that. A DataView and a loop are enough.


What it sees and what it doesn't

The picture never leaves the page. It gets decoded and counted in JavaScript in your tab.

Mixpanel and Google Analytics load with Softery.io, same as on every page of the site. Here's what they get from this tool and what they don't:

They seeThey never get
that someone opened the toolthe picture
how the picture came in (file, paste or the sample)the file name
a size band for the file, like under 1 MBthe hex codes
a band for how many colors came backthe exported text
which export format got copied or downloadedanything inside the PNG or the .ase
the count you set on the sliderthe pixels themselves

The palette itself doesn't get saved. Refresh and the page is empty again.


What to do with it

If you've got a picture and want its colors in code:

  1. Open Color Palette From Image and drop the picture, or copy a screenshot and press Ctrl+V on the page.
  2. Pick a count. Six is a good start for a photo. A flat logo will tell you how many it really has.
  3. Pick a format and press Copy. CSS variables and Tailwind v4 paste straight into a stylesheet.
  4. Check text against the backgrounds you picked with the contrast checker. Swatches that look fine together can still fail WCAG as text and background.
  5. If a design tool wants oklch or hsl instead of hex, run the swatch through the color format converter.

The sample is right there on the page if you want to see the beach come back exact first.


Last updated: November 18, 2026 | Reading time: 10 minutes

Written by Softery.io, which painted a beach pixel by pixel to have something to test against.