Merge pull request #1841 from ykmm/atlas-toomanyfiles-fix

Avoids the "Too many open files" error in case of a large number of inpu...
This commit is contained in:
akshayaurora 2014-02-01 11:30:09 -08:00
commit e797134913
1 changed files with 7 additions and 1 deletions

View File

@ -254,7 +254,13 @@ class Atlas(EventDispatcher):
size_w = size_h = int(size)
# open all of the images
ims = [(f, Image.open(f)) for f in filenames]
ims = list()
for f in filenames:
fp = open(f)
im = Image.open(fp)
im.load()
fp.close()
ims.append((f, im))
# sort by image area
ims = sorted(ims, key=lambda im: im[1].size[0] * im[1].size[1],