paul@0 | 1 | #!/usr/bin/env python |
paul@0 | 2 | |
paul@56 | 3 | """ |
paul@56 | 4 | Convert and optimise images for display in an Acorn Electron MODE 1 variant |
paul@67 | 5 | with four colours per line but eight colours available for selection on each |
paul@56 | 6 | line. |
paul@56 | 7 | |
paul@56 | 8 | Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> |
paul@56 | 9 | |
paul@56 | 10 | This program is free software; you can redistribute it and/or modify it under |
paul@56 | 11 | the terms of the GNU General Public License as published by the Free Software |
paul@56 | 12 | Foundation; either version 3 of the License, or (at your option) any later |
paul@56 | 13 | version. |
paul@56 | 14 | |
paul@56 | 15 | This program is distributed in the hope that it will be useful, but WITHOUT ANY |
paul@56 | 16 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
paul@56 | 17 | PARTICULAR PURPOSE. See the GNU General Public License for more details. |
paul@56 | 18 | |
paul@56 | 19 | You should have received a copy of the GNU General Public License along |
paul@56 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@56 | 21 | """ |
paul@56 | 22 | |
paul@58 | 23 | from random import random, randrange |
paul@56 | 24 | from os.path import split, splitext |
paul@12 | 25 | import EXIF |
paul@0 | 26 | import PIL.Image |
paul@60 | 27 | import itertools |
paul@20 | 28 | import math |
paul@0 | 29 | import sys |
paul@0 | 30 | |
paul@20 | 31 | corners = [ |
paul@20 | 32 | (0, 0, 0), (255, 0, 0), (0, 255, 0), (255, 255, 0), |
paul@20 | 33 | (0, 0, 255), (255, 0, 255), (0, 255, 255), (255, 255, 255) |
paul@0 | 34 | ] |
paul@0 | 35 | |
paul@56 | 36 | # Basic colour operations. |
paul@56 | 37 | |
paul@49 | 38 | def within(v, lower, upper): |
paul@49 | 39 | return min(max(v, lower), upper) |
paul@49 | 40 | |
paul@49 | 41 | def clip(v): |
paul@69 | 42 | return int(within(v, 0, 255)) |
paul@49 | 43 | |
paul@20 | 44 | def distance(rgb1, rgb2): |
paul@20 | 45 | r1, g1, b1 = rgb1 |
paul@20 | 46 | r2, g2, b2 = rgb2 |
paul@20 | 47 | return math.sqrt(pow(r1 - r2, 2) + pow(g1 - g2, 2) + pow(b1 - b2, 2)) |
paul@20 | 48 | |
paul@35 | 49 | def restore(srgb): |
paul@35 | 50 | return tuple(map(lambda x: int(x * 255.0), srgb)) |
paul@35 | 51 | |
paul@34 | 52 | def scale(rgb): |
paul@34 | 53 | return tuple(map(lambda x: x / 255.0, rgb)) |
paul@34 | 54 | |
paul@34 | 55 | def invert(srgb): |
paul@34 | 56 | return tuple(map(lambda x: 1.0 - x, srgb)) |
paul@34 | 57 | |
paul@56 | 58 | # Colour distribution functions. |
paul@56 | 59 | |
paul@34 | 60 | def combination(rgb): |
paul@56 | 61 | |
paul@56 | 62 | "Return the colour distribution for 'rgb'." |
paul@56 | 63 | |
paul@63 | 64 | # Get the colour with components scaled from 0 to 1, plus the inverted |
paul@63 | 65 | # component values. |
paul@56 | 66 | |
paul@67 | 67 | rgb = scale(rgb) |
paul@63 | 68 | rgbi = invert(rgb) |
paul@63 | 69 | pairs = zip(rgbi, rgb) |
paul@56 | 70 | |
paul@63 | 71 | # For each corner of the colour cube (primary and secondary colours plus |
paul@63 | 72 | # black and white), calculate the corner value's contribution to the |
paul@63 | 73 | # input colour. |
paul@56 | 74 | |
paul@63 | 75 | d = [] |
paul@63 | 76 | for corner in corners: |
paul@63 | 77 | rs, gs, bs = scale(corner) |
paul@56 | 78 | |
paul@63 | 79 | # Obtain inverted channel values where corner channels are low; |
paul@63 | 80 | # obtain original channel values where corner channels are high. |
paul@56 | 81 | |
paul@63 | 82 | d.append((pairs[0][int(rs)] * pairs[1][int(gs)] * pairs[2][int(bs)], corner)) |
paul@56 | 83 | |
paul@63 | 84 | # Balance the corner contributions. |
paul@63 | 85 | |
paul@63 | 86 | return balance(d) |
paul@35 | 87 | |
paul@35 | 88 | def complements(rgb): |
paul@56 | 89 | |
paul@56 | 90 | "Return 'rgb' and its complement." |
paul@56 | 91 | |
paul@35 | 92 | r, g, b = rgb |
paul@35 | 93 | return rgb, restore(invert(scale(rgb))) |
paul@35 | 94 | |
paul@35 | 95 | def balance(d): |
paul@56 | 96 | |
paul@56 | 97 | """ |
paul@56 | 98 | Balance distribution 'd', cancelling opposing values and their complements |
paul@56 | 99 | and replacing their common contributions with black and white contributions. |
paul@56 | 100 | """ |
paul@56 | 101 | |
paul@35 | 102 | d = dict([(value, f) for f, value in d]) |
paul@59 | 103 | for primary, secondary in map(complements, [(0, 0, 0), (255, 0, 0), (0, 255, 0), (0, 0, 255)]): |
paul@35 | 104 | common = min(d[primary], d[secondary]) |
paul@35 | 105 | d[primary] -= common |
paul@35 | 106 | d[secondary] -= common |
paul@35 | 107 | return [(f, value) for value, f in d.items()] |
paul@20 | 108 | |
paul@34 | 109 | def combine(d): |
paul@56 | 110 | |
paul@56 | 111 | "Combine distribution 'd' to get a colour value." |
paul@56 | 112 | |
paul@34 | 113 | out = [0, 0, 0] |
paul@34 | 114 | for v, rgb in d: |
paul@34 | 115 | out[0] += v * rgb[0] |
paul@34 | 116 | out[1] += v * rgb[1] |
paul@34 | 117 | out[2] += v * rgb[2] |
paul@34 | 118 | return out |
paul@34 | 119 | |
paul@48 | 120 | def pattern(rgb, chosen=None): |
paul@56 | 121 | |
paul@56 | 122 | """ |
paul@56 | 123 | Obtain a sorted colour distribution for 'rgb', optionally limited to any |
paul@56 | 124 | specified 'chosen' colours. |
paul@56 | 125 | """ |
paul@56 | 126 | |
paul@60 | 127 | l = [(f, value) for f, value in combination(rgb) if not chosen or value in chosen] |
paul@32 | 128 | l.sort(reverse=True) |
paul@20 | 129 | return l |
paul@19 | 130 | |
paul@60 | 131 | def get_value(rgb, chosen=None, fail=False): |
paul@56 | 132 | |
paul@56 | 133 | """ |
paul@56 | 134 | Get an output colour for 'rgb', optionally limited to any specified 'chosen' |
paul@60 | 135 | colours. If 'fail' is set to a true value, return None if the colour cannot |
paul@60 | 136 | be expressed using any of the chosen colours. |
paul@56 | 137 | """ |
paul@56 | 138 | |
paul@48 | 139 | l = pattern(rgb, chosen) |
paul@48 | 140 | limit = sum([f for f, c in l]) |
paul@58 | 141 | if not limit: |
paul@60 | 142 | if fail: |
paul@60 | 143 | return None |
paul@60 | 144 | else: |
paul@60 | 145 | return l[randrange(0, len(l))][1] |
paul@58 | 146 | |
paul@48 | 147 | choose = random() * limit |
paul@32 | 148 | threshold = 0 |
paul@48 | 149 | for f, c in l: |
paul@32 | 150 | threshold += f |
paul@32 | 151 | if choose < threshold: |
paul@32 | 152 | return c |
paul@32 | 153 | return c |
paul@0 | 154 | |
paul@56 | 155 | # Colour processing operations. |
paul@56 | 156 | |
paul@21 | 157 | def sign(x): |
paul@21 | 158 | return x >= 0 and 1 or -1 |
paul@21 | 159 | |
paul@22 | 160 | def saturate_rgb(rgb, exp): |
paul@22 | 161 | return tuple([saturate_value(x, exp) for x in rgb]) |
paul@21 | 162 | |
paul@22 | 163 | def saturate_value(x, exp): |
paul@24 | 164 | return int(127.5 + sign(x - 127.5) * 127.5 * pow(abs(x - 127.5) / 127.5, exp)) |
paul@21 | 165 | |
paul@49 | 166 | def amplify_rgb(rgb, exp): |
paul@49 | 167 | return tuple([amplify_value(x, exp) for x in rgb]) |
paul@49 | 168 | |
paul@49 | 169 | def amplify_value(x, exp): |
paul@49 | 170 | return int(pow(x / 255.0, exp) * 255.0) |
paul@49 | 171 | |
paul@56 | 172 | # Image operations. |
paul@56 | 173 | |
paul@50 | 174 | def get_colours(im, y): |
paul@56 | 175 | |
paul@56 | 176 | "Get a colour distribution from image 'im' for the row 'y'." |
paul@56 | 177 | |
paul@50 | 178 | width, height = im.size |
paul@49 | 179 | c = {} |
paul@49 | 180 | for x in range(0, width): |
paul@49 | 181 | rgb = im.getpixel((x, y)) |
paul@49 | 182 | |
paul@49 | 183 | # Sum the colour probabilities. |
paul@49 | 184 | |
paul@49 | 185 | for f, value in combination(rgb): |
paul@49 | 186 | if not c.has_key(value): |
paul@49 | 187 | c[value] = f |
paul@49 | 188 | else: |
paul@49 | 189 | c[value] += f |
paul@49 | 190 | |
paul@75 | 191 | d = [(n/width, value) for value, n in c.items()] |
paul@75 | 192 | d.sort(reverse=True) |
paul@75 | 193 | return d |
paul@33 | 194 | |
paul@60 | 195 | def get_combinations(c, n): |
paul@60 | 196 | |
paul@60 | 197 | """ |
paul@60 | 198 | Get combinations of colours from 'c' of size 'n' in decreasing order of |
paul@60 | 199 | probability. |
paul@60 | 200 | """ |
paul@60 | 201 | |
paul@60 | 202 | all = [] |
paul@60 | 203 | for l in itertools.combinations(c, n): |
paul@60 | 204 | total = 0 |
paul@60 | 205 | for f, value in l: |
paul@60 | 206 | total += f |
paul@60 | 207 | all.append((total, l)) |
paul@60 | 208 | all.sort(reverse=True) |
paul@60 | 209 | return [l for total, l in all] |
paul@60 | 210 | |
paul@20 | 211 | def test(): |
paul@56 | 212 | |
paul@56 | 213 | "Generate slices of the colour cube." |
paul@56 | 214 | |
paul@20 | 215 | size = 512 |
paul@20 | 216 | for r in (0, 63, 127, 191, 255): |
paul@20 | 217 | im = PIL.Image.new("RGB", (size, size)) |
paul@20 | 218 | for g in range(0, size): |
paul@20 | 219 | for b in range(0, size): |
paul@28 | 220 | value = get_value((r, (g * 256) / size, (b * 256 / size))) |
paul@20 | 221 | im.putpixel((g, b), value) |
paul@20 | 222 | im.save("rgb%d.png" % r) |
paul@20 | 223 | |
paul@20 | 224 | def test_flat(rgb): |
paul@56 | 225 | |
paul@56 | 226 | "Generate a flat image for the colour 'rgb'." |
paul@56 | 227 | |
paul@20 | 228 | size = 64 |
paul@20 | 229 | im = PIL.Image.new("RGB", (size, size)) |
paul@20 | 230 | for y in range(0, size): |
paul@20 | 231 | for x in range(0, size): |
paul@28 | 232 | im.putpixel((x, y), get_value(rgb)) |
paul@20 | 233 | im.save("rgb%02d%02d%02d.png" % rgb) |
paul@20 | 234 | |
paul@50 | 235 | def rotate_and_scale(exif, im, width, height, rotate): |
paul@56 | 236 | |
paul@56 | 237 | """ |
paul@56 | 238 | Using the given 'exif' information, rotate and scale image 'im' given the |
paul@56 | 239 | indicated 'width' and 'height' constraints and any explicit 'rotate' |
paul@56 | 240 | indication. The returned image will be within the given 'width' and |
paul@56 | 241 | 'height', filling either or both, and preserve its original aspect ratio. |
paul@56 | 242 | """ |
paul@56 | 243 | |
paul@50 | 244 | if rotate or exif and exif["Image Orientation"].values == [6L]: |
paul@11 | 245 | im = im.rotate(270) |
paul@19 | 246 | |
paul@4 | 247 | w, h = im.size |
paul@19 | 248 | if w > h: |
paul@19 | 249 | height = (width * h) / w |
paul@19 | 250 | else: |
paul@19 | 251 | width = (height * w) / h |
paul@19 | 252 | |
paul@20 | 253 | return im.resize((width, height)) |
paul@1 | 254 | |
paul@50 | 255 | def count_colours(im, colours): |
paul@56 | 256 | |
paul@56 | 257 | """ |
paul@56 | 258 | Count colours on each row of image 'im', returning a tuple indicating the |
paul@56 | 259 | first row with more than the given number of 'colours' together with the |
paul@56 | 260 | found colours; otherwise returning None. |
paul@56 | 261 | """ |
paul@56 | 262 | |
paul@50 | 263 | width, height = im.size |
paul@70 | 264 | |
paul@50 | 265 | for y in range(0, height): |
paul@50 | 266 | l = set() |
paul@50 | 267 | for x in range(0, width): |
paul@50 | 268 | l.add(im.getpixel((x, y))) |
paul@50 | 269 | if len(l) > colours: |
paul@50 | 270 | return (y, l) |
paul@50 | 271 | return None |
paul@50 | 272 | |
paul@75 | 273 | def process_image(pim, saturate, desaturate, darken, brighten): |
paul@70 | 274 | |
paul@70 | 275 | """ |
paul@75 | 276 | Process image 'pim' using the given options: 'saturate', 'desaturate', |
paul@70 | 277 | 'darken', 'brighten'. |
paul@70 | 278 | """ |
paul@70 | 279 | |
paul@75 | 280 | width, height = pim.size |
paul@75 | 281 | im = SimpleImage(list(pim.getdata()), pim.size) |
paul@70 | 282 | |
paul@70 | 283 | if saturate or desaturate or darken or brighten: |
paul@70 | 284 | for y in range(0, height): |
paul@70 | 285 | for x in range(0, width): |
paul@70 | 286 | rgb = im.getpixel((x, y)) |
paul@70 | 287 | if saturate or desaturate: |
paul@70 | 288 | rgb = saturate_rgb(rgb, saturate and 0.5 / saturate or 2 * desaturate) |
paul@70 | 289 | if darken or brighten: |
paul@70 | 290 | rgb = amplify_rgb(rgb, brighten and 0.5 / brighten or 2 * darken) |
paul@70 | 291 | im.putpixel((x, y), rgb) |
paul@70 | 292 | |
paul@75 | 293 | pim.putdata(im.getdata()) |
paul@70 | 294 | |
paul@75 | 295 | def preview_image(pim, half_resolution_preview=False): |
paul@70 | 296 | |
paul@75 | 297 | "Return a preview copy of image 'pim'." |
paul@70 | 298 | |
paul@75 | 299 | width, height = pim.size |
paul@75 | 300 | imp = pim.copy() |
paul@75 | 301 | im = SimpleImage(list(pim.getdata()), pim.size) |
paul@70 | 302 | step = half_resolution_preview and 2 or 1 |
paul@70 | 303 | |
paul@70 | 304 | for y in range(0, height): |
paul@75 | 305 | for x in range(0, width): |
paul@75 | 306 | rgb = im.getpixel((x, y)) |
paul@70 | 307 | value = get_value(rgb) |
paul@75 | 308 | im.putpixel((x, y), value) |
paul@70 | 309 | if half_resolution_preview: |
paul@75 | 310 | im.putpixel((x+1, y), value) |
paul@70 | 311 | |
paul@75 | 312 | imp.putdata(im.getdata()) |
paul@70 | 313 | return imp |
paul@70 | 314 | |
paul@75 | 315 | def convert_image(pim): |
paul@70 | 316 | |
paul@75 | 317 | "Convert image 'pim' to an appropriate output representation." |
paul@70 | 318 | |
paul@75 | 319 | width, height = pim.size |
paul@75 | 320 | im = SimpleImage(list(pim.getdata()), pim.size) |
paul@70 | 321 | |
paul@70 | 322 | for y in range(0, height): |
paul@70 | 323 | c = get_colours(im, y) |
paul@70 | 324 | |
paul@70 | 325 | for l in get_combinations(c, 4): |
paul@70 | 326 | most = [value for f, value in l] |
paul@70 | 327 | for x in range(0, width): |
paul@70 | 328 | rgb = im.getpixel((x, y)) |
paul@70 | 329 | value = get_value(rgb, most, True) |
paul@70 | 330 | if value is None: |
paul@70 | 331 | break # try next combination |
paul@70 | 332 | else: |
paul@70 | 333 | break # use this combination |
paul@70 | 334 | else: |
paul@70 | 335 | most = [value for f, value in c[:4]] # use the first four |
paul@70 | 336 | |
paul@70 | 337 | for x in range(0, width): |
paul@70 | 338 | rgb = im.getpixel((x, y)) |
paul@70 | 339 | value = get_value(rgb, most) |
paul@70 | 340 | im.putpixel((x, y), value) |
paul@70 | 341 | |
paul@70 | 342 | if x < width - 1: |
paul@70 | 343 | rgbn = im.getpixel((x+1, y)) |
paul@70 | 344 | rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 4.0), zip(rgbn, rgb, value))) |
paul@70 | 345 | im.putpixel((x+1, y), rgbn) |
paul@70 | 346 | |
paul@70 | 347 | if y < height - 1: |
paul@70 | 348 | rgbn = im.getpixel((x, y+1)) |
paul@70 | 349 | rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 2.0), zip(rgbn, rgb, value))) |
paul@70 | 350 | im.putpixel((x, y+1), rgbn) |
paul@70 | 351 | |
paul@75 | 352 | pim.putdata(im.getdata()) |
paul@75 | 353 | |
paul@65 | 354 | def get_float(options, flag): |
paul@65 | 355 | try: |
paul@65 | 356 | i = options.index(flag) |
paul@66 | 357 | if i+1 < len(options) and options[i+1].isdigit(): |
paul@65 | 358 | return float(options[i+1]) |
paul@65 | 359 | else: |
paul@65 | 360 | return 1.0 |
paul@65 | 361 | except ValueError: |
paul@65 | 362 | return 0.0 |
paul@65 | 363 | |
paul@75 | 364 | class SimpleImage: |
paul@75 | 365 | |
paul@75 | 366 | "An image behaving like PIL.Image." |
paul@75 | 367 | |
paul@75 | 368 | def __init__(self, data, size): |
paul@75 | 369 | self.data = data |
paul@75 | 370 | self.width, self.height = self.size = size |
paul@75 | 371 | |
paul@75 | 372 | def copy(self): |
paul@75 | 373 | return SimpleImage(self.data[:], self.size) |
paul@75 | 374 | |
paul@75 | 375 | def getpixel(self, xy): |
paul@75 | 376 | x, y = xy |
paul@75 | 377 | return self.data[y * self.width + x] |
paul@75 | 378 | |
paul@75 | 379 | def putpixel(self, xy, value): |
paul@75 | 380 | x, y = xy |
paul@75 | 381 | self.data[y * self.width + x] = value |
paul@75 | 382 | |
paul@75 | 383 | def getdata(self): |
paul@75 | 384 | return self.data |
paul@75 | 385 | |
paul@56 | 386 | # Main program. |
paul@56 | 387 | |
paul@20 | 388 | if __name__ == "__main__": |
paul@56 | 389 | |
paul@56 | 390 | # Test options. |
paul@56 | 391 | |
paul@20 | 392 | if "--test" in sys.argv: |
paul@20 | 393 | test() |
paul@20 | 394 | sys.exit(0) |
paul@20 | 395 | elif "--test-flat" in sys.argv: |
paul@20 | 396 | test_flat((120, 40, 60)) |
paul@20 | 397 | sys.exit(0) |
paul@56 | 398 | elif "--help" in sys.argv: |
paul@56 | 399 | print >>sys.stderr, """\ |
paul@56 | 400 | Usage: %s <input filename> <output filename> [ <options> ] |
paul@56 | 401 | |
paul@56 | 402 | Options are... |
paul@56 | 403 | |
paul@67 | 404 | -s - Saturate the input image (can be followed by a float, default 1.0) |
paul@67 | 405 | -d - Desaturate the input image (can be followed by a float, default 1.0) |
paul@65 | 406 | -D - Darken the input image (can be followed by a float, default 1.0) |
paul@65 | 407 | -B - Brighten the input image (can be followed by a float, default 1.0) |
paul@56 | 408 | |
paul@56 | 409 | -r - Rotate the input image clockwise |
paul@56 | 410 | -p - Generate a separate preview image |
paul@56 | 411 | -h - Make the preview image with half horizontal resolution (MODE 2) |
paul@56 | 412 | -v - Verify the output image (loaded if -n is given) |
paul@56 | 413 | -n - Generate no output image |
paul@56 | 414 | """ % split(sys.argv[0])[1] |
paul@56 | 415 | sys.exit(1) |
paul@0 | 416 | |
paul@20 | 417 | width = 320 |
paul@20 | 418 | height = 256 |
paul@20 | 419 | |
paul@20 | 420 | input_filename, output_filename = sys.argv[1:3] |
paul@26 | 421 | basename, ext = splitext(output_filename) |
paul@35 | 422 | preview_filename = "".join([basename + "_preview", ext]) |
paul@26 | 423 | |
paul@50 | 424 | options = sys.argv[3:] |
paul@1 | 425 | |
paul@56 | 426 | # Preprocessing options that can be repeated for extra effect. |
paul@56 | 427 | |
paul@67 | 428 | saturate = get_float(options, "-s") |
paul@67 | 429 | desaturate = get_float(options, "-d") |
paul@65 | 430 | darken = get_float(options, "-D") |
paul@65 | 431 | brighten = get_float(options, "-B") |
paul@64 | 432 | |
paul@56 | 433 | # General output options. |
paul@56 | 434 | |
paul@56 | 435 | rotate = "-r" in options |
paul@50 | 436 | preview = "-p" in options |
paul@50 | 437 | half_resolution_preview = "-h" in options |
paul@50 | 438 | verify = "-v" in options |
paul@50 | 439 | no_normal_output = "-n" in options |
paul@50 | 440 | make_image = not no_normal_output |
paul@1 | 441 | |
paul@56 | 442 | # Load the input image if requested. |
paul@56 | 443 | |
paul@50 | 444 | if make_image or preview: |
paul@50 | 445 | exif = EXIF.process_file(open(input_filename)) |
paul@50 | 446 | im = PIL.Image.open(input_filename).convert("RGB") |
paul@50 | 447 | im = rotate_and_scale(exif, im, width, height, rotate) |
paul@50 | 448 | |
paul@70 | 449 | process_image(im, saturate, desaturate, darken, brighten) |
paul@10 | 450 | |
paul@56 | 451 | # Generate a preview if requested. |
paul@56 | 452 | |
paul@35 | 453 | if preview: |
paul@70 | 454 | preview_image(im, half_resolution_preview).save(preview_filename) |
paul@35 | 455 | |
paul@56 | 456 | # Generate an output image if requested. |
paul@56 | 457 | |
paul@50 | 458 | if make_image: |
paul@70 | 459 | convert_image(im) |
paul@50 | 460 | im.save(output_filename) |
paul@1 | 461 | |
paul@56 | 462 | # Verify the output image (which may be loaded) if requested. |
paul@56 | 463 | |
paul@50 | 464 | if verify: |
paul@50 | 465 | if no_normal_output: |
paul@50 | 466 | im = PIL.Image.open(output_filename).convert("RGB") |
paul@49 | 467 | |
paul@50 | 468 | result = count_colours(im, 4) |
paul@50 | 469 | if result is not None: |
paul@50 | 470 | y, colours = result |
paul@56 | 471 | print "Image %s: row %d has the following colours: %s" % (output_filename, y, "; ".join([repr(c) for c in colours])) |
paul@0 | 472 | |
paul@0 | 473 | # vim: tabstop=4 expandtab shiftwidth=4 |