Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: imageConversion.py

Issue 6099042538881024: Wait until images are loaded (Closed)
Patch Set: Created Nov. 16, 2013, 2 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld