colorsys.rgb_to_hls()
colorsys.rgb_to_hls() is a Python function in the Colorsys Module category. Converts RGB color values (0-1) to HLS (hue, lightness, saturation). The syntax is colorsys.rgb_to_hls(r, g, b). Returns: (h, l, s) tuple. A typical example: import colorsys
colorsys.rgb_to_hls(1.0, 0.0, 0.0) # (0.0, 0.5, 1.0) — red as HLS. A close sibling is colorsys.hls_to_rgb(), which converts HLS color values back to RGB. A close sibling is colorsys.rgb_to_hsv(), which converts RGB to HSV (hue, saturation, value). A close sibling is colorsys.hsv_to_rgb(), which converts HSV back to RGB. A close sibling is colorsys.rgb_to_yiq(), which converts RGB to YIQ (used in NTSC TV). More about this category: Color system conversions — rgb_to_hls, hls_to_rgb, rgb_to_hsv, hsv_to_rgb. Related Colorsys Module entries: colorsys.hls_to_rgb(), colorsys.rgb_to_hsv(), colorsys.hsv_to_rgb(), colorsys.rgb_to_yiq(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try colorsys.rgb_to_hls() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.