# HG changeset patch # User Paul Boddie # Date 1444385056 -7200 # Node ID 6890aa1afe3e83b330251ee3b9e4bbfbc2bfb54a # Parent 14cf81e93dd46340b35daf7f72b521beaef9fe25 Changed darken/brighten to use numeric parameters. diff -r 14cf81e93dd4 -r 6890aa1afe3e optimiser.py --- a/optimiser.py Fri Oct 09 01:30:38 2015 +0200 +++ b/optimiser.py Fri Oct 09 12:04:16 2015 +0200 @@ -274,6 +274,16 @@ return (y, l) return None +def get_float(options, flag): + try: + i = options.index(flag) + if options[i+1].isdigit(): + return float(options[i+1]) + else: + return 1.0 + except ValueError: + return 0.0 + # Main program. if __name__ == "__main__": @@ -294,8 +304,8 @@ -s - Saturate the input image (can be repeated) -d - Desaturate the input image (can be repeated) --D - Darken the input image (can be repeated or followed by a float) --B - Brighten the input image (can be repeated or followed by a float) +-D - Darken the input image (can be followed by a float, default 1.0) +-B - Brighten the input image (can be followed by a float, default 1.0) -2 - Square/diminish the bright corner colour contributions (experimental) -r - Rotate the input image clockwise @@ -319,17 +329,8 @@ saturate = options.count("-s") desaturate = options.count("-d") - darken = options.count("-D") - brighten = options.count("-B") - - if darken == 1: - i = options.index("-D") - if options[i+1].isdigit(): - darken = float(options[i+1]) - if brighten == 1: - i = options.index("-B") - if options[i+1].isdigit(): - brighten = float(options[i+1]) + darken = get_float(options, "-D") + brighten = get_float(options, "-B") # Experimental colour distribution modification.