# HG changeset patch # User Paul Boddie # Date 1443659874 -7200 # Node ID aabad380ed5941da6bfa64f40abb2d671613aa18 # Parent d33be469e542d053c25ae5ef48b4bd9131782e01 Permit stronger saturation and desaturation using multiple option flags. diff -r d33be469e542 -r aabad380ed59 optimiser.py --- a/optimiser.py Thu Oct 01 02:24:13 2015 +0200 +++ b/optimiser.py Thu Oct 01 02:37:54 2015 +0200 @@ -117,8 +117,8 @@ input_filename, output_filename = sys.argv[1:3] rotate = "-r" in sys.argv[3:] - saturate = "-s" in sys.argv[3:] - desaturate = "-d" in sys.argv[3:] + saturate = sys.argv[3:].count("-s") + desaturate = sys.argv[3:].count("-d") x = EXIF.process_file(open(input_filename)) im = PIL.Image.open(input_filename) @@ -133,7 +133,7 @@ for x in range(0, width): rgb = im.getpixel((x, y)) if saturate or desaturate: - rgb = saturate_rgb(rgb, saturate and 0.5 or 2) + rgb = saturate_rgb(rgb, saturate and math.pow(0.5, saturate) or math.pow(2, desaturate)) value = get_value((x, y), rgb, width, height) im.putpixel((x, y), value) if not c.has_key(value):