Python colorsys Module
Example
Convert RGB to HSV:
import colorsys
h, s, v = colorsys.rgb_to_hsv(0.5, 0.25, 0.75)
print(round(h, 3), round(s, 3), round(v, 3))
Try it Yourself »
Definition and Usage
The colorsys module converts colors between RGB and other color systems like HSV and HLS.
Use it to convert colors for visualizations, UI, or image processing tasks.
Members
Member | Description |
---|---|
hls_to_rgb() | Convert from HLS to RGB. |
hsv_to_rgb() | Convert from HSV to RGB. |
rgb_to_hls() | Convert from RGB to HLS. |
rgb_to_hsv() | Convert from RGB to HSV. |
rgb_to_yiq() | Convert from RGB to YIQ. |
yiq_to_rgb() | Convert from YIQ to RGB. |