There’s a ColorExtractor thing which can do it for one color, and the underlying Color Thief library¹ supports getting a palette of a given number of colors. I just need to figure out how to hook it up in the easiest way… ideally without writing a bunch of code. 😅

¹https://github.com/fengsp/color-thief-py