obskyr / colorgram.py

A Python module for extracting colors from images. Get a palette of any picture!
MIT License
447 stars 50 forks source link

hex property for Color objects #2

Open ewen-lbh opened 5 years ago

ewen-lbh commented 5 years ago

I'd like to have an extra .hex property in the Color object, that contains a string representing the hexadecimal color code. eg.

>>> print(my_color.hex)
'#0A1FB5'
EmilStenstrom commented 4 years ago

I first thought I needed this too, but then remembered that CSS supports RGB colors too. So converting a Color object to one usable in CSS is just:

css_color = f"rgb({color.rgb.r}, {color.rgb.g}, {color.rgb.b})"
DonaldTsang commented 3 years ago

I would second this, but also include HSB/HSV, HCL, HCB/HCV, YCbCr, YCoCg, and others. Who wanna do a pull request? This should be easy as PIE