def _get_img_with_all_operations(): logger.debug(operations) b = operations.brightness c = operations.contrast s = operations.sharpness img = _img_preview if b != 0: img = img_helper.brightness(img, b) if c != 0: img = img_helper.contrast(img, c) if s != 0: img = img_helper.sharpness(img, s) if operations.rotation_angle: img = img_helper.rotate(img, operations.rotation_angle) if operations.flip_left: img = img_helper.flip_left(img) if operations.flip_top: img = img_helper.flip_top(img) if operations.size: img = img_helper.resize(img, *operations.size) return img
def init(): """Get and parse parameters from console""" args = sys.argv[1:] if len(args) == 0: logger.error("-p can't be empty") raise ValueError("-p can't be empty") logger.debug(f"run with params: {args}") # transform arguments from console opts, rem = getopt.getopt( args, "p:", ["rotate=", "resize=", "color_filter=", "flip_top", "flip_left"]) rotate_angle = resize = color_filter = flip_top = flip_left = None path = None for opt, arg in opts: if opt == "-p": path = arg elif opt == "--rotate": rotate_angle = int(arg) elif opt == "--resize": resize = arg elif opt == "--color_filter": color_filter = arg elif opt == "--flip_top": flip_top = True elif opt == "--flip_left": flip_left = arg if not path: raise ValueError("No path") img = img_helper.get_img(path) if rotate_angle: img = img_helper.rotate(img, rotate_angle) if resize: w, h = map(int, resize.split(',')) img = img_helper.resize(img, w, h) if color_filter: img = img_helper.color_filter(img, color_filter) if flip_left: img = img_helper.flip_left(img) if flip_top: img = img_helper.flip_top(img) if __debug__: img.show()
def _get_img_with_all_operations(): b = operations.brightness c = operations.contrast s = operations.sharpness img = _img_preview if b != 0: img = img_helper.brightness(img, b) if c != 0: img = img_helper.contrast(img, c) if s != 0: img = img_helper.sharpness(img, s) if operations.rotation_angle: img = img_helper.rotate(img, operations.rotation_angle) if operations.flip_left: img = img_helper.flip_left(img) if operations.flip_top: img = img_helper.flip_top(img) if operations.size: img = img_helper.resize(img, *operations.size) if operations.red != operations.red_prev: img = img_helper.hist_red(img, operations.red, operations.red_prev) operations.red_prev = operations.red if operations.green != operations.green_prev: img = img_helper.hist_green(img, operations.green, operations.green_prev) operations.green_prev = operations.green if operations.blue != operations.blue_prev: img = img_helper.hist_blue(img, operations.blue, operations.blue_prev) operations.blue_prev = operations.blue return img