| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This file is part of the Adblock Plus build tools, | 3 # This file is part of the Adblock Plus build tools, |
| 4 # Copyright (C) 2006-2013 Eyeo GmbH | 4 # Copyright (C) 2006-2013 Eyeo GmbH |
| 5 # | 5 # |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
| 7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
| 8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
| 9 # | 9 # |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 image, overlay = ensure_same_mode(image, overlay) | 110 image, overlay = ensure_same_mode(image, overlay) |
| 111 return Image.blend(image, overlay, float(opacity)) | 111 return Image.blend(image, overlay, float(opacity)) |
| 112 | 112 |
| 113 def convertImages(params, files): | 113 def convertImages(params, files): |
| 114 metadata = params['metadata'] | 114 metadata = params['metadata'] |
| 115 | 115 |
| 116 for filename, chain in metadata.items('convert_img'): | 116 for filename, chain in metadata.items('convert_img'): |
| 117 baseDir = os.path.dirname(metadata.option_source('convert_img', filename)) | 117 baseDir = os.path.dirname(metadata.option_source('convert_img', filename)) |
| 118 steps = re.split(r'\s*->\s*', chain) | 118 steps = re.split(r'\s*->\s*', chain) |
| 119 image = Image.open(os.path.join(baseDir, *steps.pop(0).split('/'))) | 119 image = Image.open(os.path.join(baseDir, *steps.pop(0).split('/'))) |
| 120 image.load() |
| 120 | 121 |
| 121 for step in steps: | 122 for step in steps: |
| 122 filter, args = re.match(r'([^(]+)(?:\((.*)\))?', step).groups() | 123 filter, args = re.match(r'([^(]+)(?:\((.*)\))?', step).groups() |
| 123 args = re.split(r'\s*,\s*', args) if args else () | 124 args = re.split(r'\s*,\s*', args) if args else () |
| 124 image = globals()['filter_' + filter](image, baseDir, *args) | 125 image = globals()['filter_' + filter](image, baseDir, *args) |
| 125 | 126 |
| 126 f = StringIO() | 127 f = StringIO() |
| 127 f.name = filename | 128 f.name = filename |
| 128 image.save(f) | 129 image.save(f) |
| 129 files[filename] = f.getvalue() | 130 files[filename] = f.getvalue() |
| OLD | NEW |