RGB to HSV in Python with colorsys


Python tip:

You can use colorsys to convert colors between different color systems.

https://docs.python.org/3/library/colorsys.html

RGB to HSV👇

import colorsys

# we need values between 0 and 1, you need to divide by 255
rgb = (0.00, 0.19, 0.56)  # 00308F | (0, 48, 143) -> AirForce Blue

print(colorsys.rgb_to_hsv(*rgb))
# => (0.6101190476190476, 1.0, 0.56)