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

Unified Diff: imageConversion.py

Issue 6099042538881024: Wait until images are loaded (Closed)
Patch Set: Also make sure the image is loaded in filter_blend(), add a comment Created Nov. 16, 2013, 3:10 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: imageConversion.py
===================================================================
--- a/imageConversion.py
+++ b/imageConversion.py
@@ -39,6 +39,12 @@
return image.point(table, 'L')
+def load_image(path):
+ image = Image.open(path)
+ # Make sure the image is loaded, some versions of PIL load images lazily.
+ image.load()
+ return image
+
def ensure_same_mode(im1, im2):
# if both images already have the same mode (and palette, in
# case of mode P), don't convert anything. Images with mode P,
@@ -88,7 +94,7 @@
if len(args) == 2:
filename, opacity = args
- overlay = Image.open(os.path.join(
+ overlay = load_image(os.path.join(
baseDir,
*filename.split('/')
))
@@ -116,8 +122,7 @@
for filename, chain in metadata.items('convert_img'):
baseDir = os.path.dirname(metadata.option_source('convert_img', filename))
steps = re.split(r'\s*->\s*', chain)
- image = Image.open(os.path.join(baseDir, *steps.pop(0).split('/')))
- image.load()
+ image = load_image(os.path.join(baseDir, *steps.pop(0).split('/')))
for step in steps:
filter, args = re.match(r'([^(]+)(?:\((.*)\))?', step).groups()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld