summaryrefslogtreecommitdiff
path: root/fbin.py
diff options
context:
space:
mode:
Diffstat (limited to 'fbin.py')
-rwxr-xr-xfbin.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/fbin.py b/fbin.py
index 7339a26..138ea64 100755
--- a/fbin.py
+++ b/fbin.py
@@ -407,7 +407,7 @@ class Application(object):
def static(self, environ, start_response, path):
filename = path[1]
- if not filename in ('style.css', 'no-thumbnail.png', 'favicon.ico', 'jquery-2.1.0.min.js', 'jquery.lazyload.min.js'):
+ if not filename in ('style.css', 'no-thumbnail.png', 'favicon.ico', 'jquery-2.1.0.min.js', 'jquery.lazy.min.js'):
start_response('404 Not Found', [])
return []
@@ -462,7 +462,15 @@ class Application(object):
thumbfile = os.path.join(settings.thumb_directory, hash + '.jpg')
if not os.access(thumbfile, os.F_OK):
file = self.get_file(hash)
- im = Image.open(file.get_path())
+ try:
+ im = Image.open(file.get_path())
+ except IOError:
+ # We can't generate a thumbnail for this file, just say it doesn't exist.
+ start_response('404 Not Found', [])
+ return []
+ # Check for valid JPEG modes.
+ if im.mode not in ('1', 'L', 'RGB', 'RGBA', 'RGBX', 'CMYK', 'YCbCr'):
+ im = im.convert('RGB')
im.thumbnail(settings.thumb_size, Image.ANTIALIAS)
im.save(thumbfile)