PaletteOptimiser

Changeset

23:aabad380ed59
2015-10-01 Paul Boddie raw files shortlog changelog graph Permit stronger saturation and desaturation using multiple option flags.
optimiser.py (file)
     1.1 --- a/optimiser.py	Thu Oct 01 02:24:13 2015 +0200
     1.2 +++ b/optimiser.py	Thu Oct 01 02:37:54 2015 +0200
     1.3 @@ -117,8 +117,8 @@
     1.4  
     1.5      input_filename, output_filename = sys.argv[1:3]
     1.6      rotate = "-r" in sys.argv[3:]
     1.7 -    saturate = "-s" in sys.argv[3:]
     1.8 -    desaturate = "-d" in sys.argv[3:]
     1.9 +    saturate = sys.argv[3:].count("-s")
    1.10 +    desaturate = sys.argv[3:].count("-d")
    1.11  
    1.12      x = EXIF.process_file(open(input_filename))
    1.13      im = PIL.Image.open(input_filename)
    1.14 @@ -133,7 +133,7 @@
    1.15          for x in range(0, width):
    1.16              rgb = im.getpixel((x, y))
    1.17              if saturate or desaturate:
    1.18 -                rgb = saturate_rgb(rgb, saturate and 0.5 or 2)
    1.19 +                rgb = saturate_rgb(rgb, saturate and math.pow(0.5, saturate) or math.pow(2, desaturate))
    1.20              value = get_value((x, y), rgb, width, height)
    1.21              im.putpixel((x, y), value)
    1.22              if not c.has_key(value):