1.1 --- a/optimiserlib.py Sat Oct 10 16:41:10 2015 +0200
1.2 +++ b/optimiserlib.py Sat Oct 10 16:48:46 2015 +0200
1.3 @@ -249,6 +249,27 @@
1.4 rgb = amplify_rgb(rgb, brighten and 0.5 / brighten or 2 * darken)
1.5 im.putpixel((x, y), rgb)
1.6
1.7 +def preview_image(im, half_resolution_preview=False):
1.8 +
1.9 + "Return a preview copy of image 'im'."
1.10 +
1.11 + width, height = im.size
1.12 + imp = im.copy()
1.13 + if half_resolution_preview:
1.14 + step = 2
1.15 + else:
1.16 + step = 1
1.17 +
1.18 + for y in range(0, height):
1.19 + for x in range(0, width, step):
1.20 + rgb = im.getpixel((x, y))
1.21 + value = get_value(rgb)
1.22 + imp.putpixel((x, y), value)
1.23 + if half_resolution_preview:
1.24 + imp.putpixel((x+1, y), value)
1.25 +
1.26 + return imp
1.27 +
1.28 class SimpleImage:
1.29
1.30 "An image behaving like PIL.Image."
1.31 @@ -294,5 +315,6 @@
1.32 count_colours(im, 4)
1.33
1.34 process_image(im, 1.0, 0.0, 1.0, 0.0)
1.35 + preview_image(im, False)
1.36
1.37 # vim: tabstop=4 expandtab shiftwidth=4