diff --git a/src/util/color_reader.py b/src/util/color_reader.py index 626b711..45cc8dd 100644 --- a/src/util/color_reader.py +++ b/src/util/color_reader.py @@ -44,9 +44,10 @@ def get_hex_color_name(color): def str2color_name(s: str): if 'rgb' in s: - s = s.replace('rgb', '').replace('(', '').replace(')', '') + rgb_str = 'rgba' if ('rgba' in s) else 'rgb' + s = s.replace(rgb_str, '').replace('(', '').replace(')', '') try: - rgb = [int(x) for x in s.split(',')] + rgb = [int(x) for x in s.split(',')[:3]] rgb = tuple(rgb) except ValueError: return '' @@ -57,6 +58,11 @@ def str2color_name(s: str): elif '#' in s: name = get_hex_color_name(s) + if (name == 'white') and (s.lower() not in ['#ffffff', '#fff']): + return 'gray' + if name == 'grey': + return 'gray' + return name elif s in html4_hex_to_names.items():