Mercurial > hg > montage
changeset 11:8353caad836c
use a thumbnail if it exists even if its wrong
author | k0s <k0scist@gmail.com> |
---|---|
date | Fri, 25 Dec 2009 19:29:37 -0500 |
parents | 73d18f0cf8bb |
children | e9be444c874b |
files | montage/formatters.py setup.py |
diffstat | 2 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/montage/formatters.py Fri Dec 25 19:26:23 2009 -0500 +++ b/montage/formatters.py Fri Dec 25 19:29:37 2009 -0500 @@ -80,18 +80,20 @@ create_thumbnail = True if create_thumbnail: # do thumbnail creation - image = Image.open(filepath) try: + image = Image.open(filepath) thumbnail_image = crop_resize(image, (self.width, self.height)) - except: - continue - fd = file(thumbnail_file, 'w') - thumbnail_image.save(fd) - fd.close() + fd = file(thumbnail_file, 'w') + thumbnail_image.save(fd) + fd.close() + + except: # failure to create thumbnail + pass # fix the path to point to the thumbnail - f['path'] = '%s/%s/%s' % (f['path'].rsplit('/', 1)[0], - self.thumb_dir, - thumbnail) + if os.path.exists(thumbnail_file): + f['path'] = '%s/%s/%s' % (f['path'].rsplit('/', 1)[0], + self.thumb_dir, + thumbnail)