Reputation: 1323
I'm trying to grab the color palette from an image to reuse once I have combined multiple images, with the same color palette together. I can get use getcolor
and get the list that shows how many times each color was used and what the RGB make up of the color was. How I do take the list and pull off each 'r', 'g', 'b' value so I can create a new image palette with the same color code. I can reset the palette once I have the rgb values. I just need those values.
[(531266, (255, 123, 0)] obviously the 531266 is the number of times the color showed up, the 255 is the red value, 123 is the green value and 0 is the blue value. How do I grab it with code though.
Upvotes: 0
Views: 479
Reputation: 9172
Uuhh... Guessing here that you want to access the individual colors?
# Let's assume that 'a' contains your values
a = [(531266, (255, 123, 0))]
times, (r, g, b) = a[0]
Note: that's just a "fancy" way to do it. You could just extract every element separately using indexing, but it's most useful when looping:
for times, (r, g, b) in im.getcolors():
# do something
Upvotes: 1