comparison montage/formatters.py @ 40:77c3439e76bb default tip

py3
author Jeff Hammel <k0scist@gmail.com>
date Wed, 25 Nov 2020 11:00:17 -0800
parents 529598840f4b
children
comparison
equal deleted inserted replaced
39:529598840f4b 40:77c3439e76bb
83 create_thumbnail = True 83 create_thumbnail = True
84 84
85 else: 85 else:
86 # create a new thumbnail 86 # create a new thumbnail
87 create_thumbnail = True 87 create_thumbnail = True
88 88
89 if create_thumbnail: # do thumbnail creation 89 if create_thumbnail: # do thumbnail creation
90 90
91 flag = False 91 flag = False
92 try: 92 try:
93 image = Image.open(filepath) 93 image = Image.open(filepath)
94 thumbnail_image = crop_resize(image, (self.width, self.height)) 94 thumbnail_image = crop_resize(image, (self.width, self.height))
95 with open(thumbnail_file, 'w') as fd: 95 with open(thumbnail_file, 'w') as fd:
96 flag = True 96 flag = True
97 thumbnail_image.save(fd) 97 thumbnail_image.save(fd)
98 except Exception, e: # failure to create thumbnail 98 except Exception as e: # failure to create thumbnail
99 pass 99 pass
100 100
101 # fix the path to point to the thumbnail 101 # fix the path to point to the thumbnail
102 if os.path.exists(thumbnail_file): 102 if os.path.exists(thumbnail_file):
103 f['path'] = '%s/%s/%s' % (f['path'].rsplit('/', 1)[0], 103 f['path'] = '%s/%s/%s' % (f['path'].rsplit('/', 1)[0],