progress on updateing palete schema

This commit is contained in:
mmcwilliams 2023-11-21 13:28:49 -05:00
parent 642d53fb42
commit e8c490c3f3
2 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,6 @@
from jsonschema import validate from jsonschema import validate
from json import dumps, loads from json import dumps, loads
from common import convert_color, closest_color, create_colored_image, remove_from_list, closest_color_euclidean, closest_color_weighted_euclidean, euclidean_distance, weighted_euclidean_distance
class PalleteSchema : class PalleteSchema :
colors = None colors = None
@ -41,3 +42,16 @@ class PalleteSchema :
jsonstr = dumps(obj, indent = 4) jsonstr = dumps(obj, indent = 4)
with open(filepath, 'w') as outfile : with open(filepath, 'w') as outfile :
outfile.write(jsonstr) outfile.write(jsonstr)
def closest (self, comparison, space = 'BGR', pallete = None) :
p = pallete if pallete is not None else self.pallete
colors = normalize_colors(space, )
def normalize_colors (self, space = 'BGR', pallete = None) :
colors = []
for color in pallete :
colors.append(convert_color(color['color'], color['space'], space))
return colors