1.1 --- a/optimiser.py Sat Oct 10 16:13:09 2015 +0200
1.2 +++ b/optimiser.py Sat Oct 10 16:39:08 2015 +0200
1.3 @@ -72,28 +72,6 @@
1.4
1.5 return im.resize((width, height))
1.6
1.7 -def process_image(pim, saturate, desaturate, darken, brighten):
1.8 -
1.9 - """
1.10 - Process image 'pim' using the given options: 'saturate', 'desaturate',
1.11 - 'darken', 'brighten'.
1.12 - """
1.13 -
1.14 - width, height = pim.size
1.15 - im = SimpleImage(list(pim.getdata()), pim.size)
1.16 -
1.17 - if saturate or desaturate or darken or brighten:
1.18 - for y in range(0, height):
1.19 - for x in range(0, width):
1.20 - rgb = im.getpixel((x, y))
1.21 - if saturate or desaturate:
1.22 - rgb = saturate_rgb(rgb, saturate and 0.5 / saturate or 2 * desaturate)
1.23 - if darken or brighten:
1.24 - rgb = amplify_rgb(rgb, brighten and 0.5 / brighten or 2 * darken)
1.25 - im.putpixel((x, y), rgb)
1.26 -
1.27 - pim.putdata(im.getdata())
1.28 -
1.29 def preview_image(pim, half_resolution_preview=False):
1.30
1.31 "Return a preview copy of image 'pim'."
1.32 @@ -234,7 +212,9 @@
1.33 im = PIL.Image.open(input_filename).convert("RGB")
1.34 im = rotate_and_scale(exif, im, width, height, rotate)
1.35
1.36 - process_image(im, saturate, desaturate, darken, brighten)
1.37 + sim = SimpleImage(list(im.getdata()), im.size)
1.38 + process_image(sim, saturate, desaturate, darken, brighten)
1.39 + im.putdata(sim.getdata())
1.40
1.41 # Generate a preview if requested.
1.42
1.43 @@ -253,6 +233,7 @@
1.44 if no_normal_output:
1.45 im = PIL.Image.open(output_filename).convert("RGB")
1.46
1.47 + im = SimpleImage(list(im.getdata()), im.size)
1.48 result = count_colours(im, 4)
1.49 if result is not None:
1.50 y, colours = result