1

I have a simple code that picks the most dominant colors of an image:

from colorthief import ColorThief

color_thief = ColorThief('c:/users/dora/projects/python/album-gradient/test.jpg')
palette = color_thief.get_palette(color_count=2, quality=1)
print(palette)

This returns a list of RGB values like such: [(4, 4, 4), (226, 75, 20), (4, 162, 221)]

How can I use this list to create a 3-color gradient and then save it as an image?

martineau
  • 119,623
  • 25
  • 170
  • 301
Dora Kuflu
  • 61
  • 6
  • I maintain a package that has the gradient functionality. It is meant to do terminal and ASCII art, but the Color and GradientColor classes will work for other means. Just do "pip install terminedia", then `from terminedia import ColorGradient; g = ColorGradient([(0, (4,4,4)), (0.5, (226, 755, 20)), (1, (4, 162, 221))])`. You can then use `g[0.2]`. (and other indices between 0 and 1) to get the intermediary colors. – jsbueno Mar 16 '22 at 18:59
  • (I've just expanded this comment to a full answer on the question marked as equivalent at https://stackoverflow.com/a/71503186/108205 ) – jsbueno Mar 16 '22 at 19:27

0 Answers0