import argparse from posterize import Posterize from pallete_schema import PalleteSchema from os.path import isfile, realpath, basename parser = argparse.ArgumentParser(description='Separate an image into most similar colors specified') parser.add_argument('input', type=str, help='Input image to separate') parser.add_argument('colors', type=int, help='Number of colors to separate into') parser.add_argument('pallete', type=str, help='Pallete file') parser.add_argument('output', type=str, help='Output dir to write to') parser.add_argument('--headless', type=bool, default=False, help='Run script headless') parser.add_argument('-j', '--jobs', type=int, default=1, help="Number of jobs to run in parallel") parser.add_argument('-p', '--particles', type=int, default=17000, help="Max particles to use in entire composition") class Separate : input = '' output = '' pallete = None def __init__ (self, args) : if isfile(args.input) : self.input = realpath(args.input) else : print(f'File {args.input} does not exist') exit(1) if isfile(args.pallete) : self.pallete = PalleteSchema(args.pallete) else : print(f'File {args.pallete} does not exist') exit(2) Posterize(self.input, self.pallete, args.colors, args.output, args.headless, args.jobs, args.particles) if __name__ == "__main__" : args = parser.parse_args() Separate(args)