Why palette extractors return colours that are not in the picture
Feed a photograph of a red flower on green leaves into most palette tools and somewhere in the results will be a brown that appears nowhere in the image. It is not a bug in the sense of a mistake in the code. It is the textbook algorithm doing exactly what it says, and the fault is in a single step that looks harmless.
The algorithm is median cut. Put every pixel in one box in colour space, find the axis the box is most spread along, split it at the median, and repeat on whichever box is now the most spread out until there are as many boxes as you want colours. It is fast, it needs no tuning, and it divides an image sensibly. Then comes the step that ruins it: take the average of each box and call that the swatch. The average of a red pixel and a green pixel is brown, and if a box straddles the flower and the leaf, brown is what you get. The palette is arithmetically correct and visually a lie.
The fix costs one pass. Instead of the average, take the real pixel nearest to it. The box still says which region of colour space matters; the pixel makes sure the answer is a colour someone could have pointed at. Everything offered is then defensible, because it is in the picture.
A second, quieter error hides in what these tools report as a percentage. Median cut splits at the median, which means every box holds roughly the same number of pixels by construction. Reporting box population as a share therefore says all six colours cover about a sixth of the image each, no matter what the image looks like, and a photograph that is three-quarters sky will be described as evenly balanced. The shares have to be measured after the fact, by asking of every pixel which swatch it is nearest to. Only then does the sky come back as three-quarters.
The last thing worth mentioning is the one-pixel read. Draw an image into a canvas and read a pixel back with smoothing left on, which is the default, and the browser hands you a blend of that pixel and its neighbours. The colour is plausible, close to right, and does not match the source when you paste it into a stylesheet and compare. Turning smoothing off for that read is a single line, and it is the difference between an eyedropper and something that approximately agrees with one.