import argparse import cv2 from pallete_schema import PalleteSchema from os.path import isfile, realpath, basename, dirname, splitext, join parser = argparse.ArgumentParser(description='Separate an image into most similar colors specified') parser.add_argument('input', type=str, help='Input image to extract the pallete from') class Pallete : input = '' output = '' image = None def __init__ (self, args) : if isfile(args.input) : self.input = realpath(args.input) else : print(f'File {self.input} does not exist') exit(1) self.set_output() def set_output (self) : dir = dirname(self.input) stem = splitext(basename(self.input))[0] self.output = join(dir, f'{stem}.json') print(f'Writing to {stem}.json') def process (self) : image = cv2.imread(self.input) if __name__ == "__main__" : args = parser.parse_args() Pallete(args)