convert-color-codes

Conversion between variations of color codes. HSV/HSB or RGB or CMYK or HSL


Keywords
color, color_codes, convert_color
Install
pip install convert-color-codes==1.0.2

Documentation

convert_color_codes

The convert_color_codes module deals with the conversion of color codes. Conversion from these codes HSV/HSB, RGB, CMYK, HSL from one to another.

Installation

You can install convert_color_codes from PyPI:

pip install convert_color_codes

It is supported on Python 2, 3 ...

How to use

from convert_color_codes import *

There are several functions like rgb2hex(red, green, blue), see the table:

Source with Arguments β†’
Target and Return Value ↓
rgb2...(red, green, blue) hex2...("#RRGGBB" or "#RGB") hsl2...(hue, saturation, lightness) hsv2...(hue, saturation, value)
hsb2...(hue, saturation, brightness)
hsv2...(cyan, magenta, yellow, black)
rgb β†’ (red, green, blue) βœ“ βœ“ βœ“ βœ“
hex β†’ "#RRGGBB" βœ“ βœ“ βœ“ βœ“
hsl β†’ (hue, saturation, lightness) βœ“ βœ“ βœ“ βœ“
hsv or hsb β†’ (hue, saturation, brightness) βœ“ βœ“ βœ“ βœ“
cmyk β†’ (cyan, magenta, yellow, black) βœ“ βœ“ βœ“ βœ“

The values have different ranges:

name min max type
red 0 255 int
green 0 255 int
blue 0 255 int
R 0 F str
G 0 F str
B 0 F str
hue 0 360 int or float
saturation 0 1 float
lightness 0 1 float
value or brightness 0 1 float
cyan 0 1 float
magenta 0 1 float
yellow 0 1 float
black 0 1 float