Skip to content

Conversation

ellbur
Copy link

@ellbur ellbur commented May 2, 2025

The nearest-matching palette behavior was removed in b6b107c

This change puts it back.

I haven't managed to build it yet so I haven't tested it. I will do that next.

@jerch
Copy link
Owner

jerch commented May 2, 2025

Oh weird, this || 0 looks like some testing remnant.

Note that the encoder part of this lib is alpha and almost untested. It has serious performance issues, so I did not try to get it into better shape. Instead I might release a wasm based encoder soon (half done), which is like 10+ times faster, includes a decent quantizer already and has a very low code and memory footprint. It also uses https://github.com/jerch/inwasm, which makes the wasm parts much easier to deal with.

From a conceptual side - you should not rely on that "dumb" nearest color match implementation at all, as it does square root distance matching for every color against all colors of the given palette w'o any palette correction. Thats very very wasteful, and the palette is almost always subpar. Better use a quantizer to get an optimized palette, that is closer to the original colors.

@ellbur
Copy link
Author

ellbur commented May 2, 2025

Thanks for the info, and I'm happy to hear you're working on a faster version! For my limited purposes though, this one is plenty fast enough.

I got it to build, though I had to use a newer version of canvas since I couldn't install the older version on my computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants