# HG changeset patch # User Paul Boddie # Date 1444347038 -7200 # Node ID 14cf81e93dd46340b35daf7f72b521beaef9fe25 # Parent 4d2f52b71f3c4df24177139ddb70520fed8db762 Added parameterisation of the darken and brighten options. diff -r 4d2f52b71f3c -r 14cf81e93dd4 optimiser.py --- a/optimiser.py Fri Oct 09 00:40:59 2015 +0200 +++ b/optimiser.py Fri Oct 09 01:30:38 2015 +0200 @@ -294,8 +294,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) --B - Brighten 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) -2 - Square/diminish the bright corner colour contributions (experimental) -r - Rotate the input image clockwise @@ -322,6 +322,15 @@ 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]) + # Experimental colour distribution modification. use_square = "-2" in options @@ -353,7 +362,7 @@ if saturate or desaturate: rgb = saturate_rgb(rgb, saturate and math.pow(0.5, saturate) or math.pow(2, desaturate)) if darken or brighten: - rgb = amplify_rgb(rgb, brighten and math.pow(0.5, brighten) or math.pow(2, darken)) + rgb = amplify_rgb(rgb, brighten and 0.5 / brighten or 2 * darken) im.putpixel((x, y), rgb) # Generate a preview if requested.