From 6566b773ff772c0aefcdae0fbbf331964ab2d0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 12 Nov 2015 10:31:33 +0100 Subject: [PATCH] misc: ignore thumbnailing errors (#8954) --- wcs/forms/root.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wcs/forms/root.py b/wcs/forms/root.py index 9ec6213..096e623 100644 --- a/wcs/forms/root.py +++ b/wcs/forms/root.py @@ -942,10 +942,14 @@ class FormPage(Directory): file_pointer = get_session().get_tempfile_content(t).get_file_pointer() if Image is not None and get_request().form.get('thumbnail') == '1': - image = Image.open(file_pointer) - image.thumbnail((500, 300)) - image_thumb_fp = StringIO() - image.save(image_thumb_fp, "PNG") + try: + image = Image.open(file_pointer) + image.thumbnail((500, 300)) + image_thumb_fp = StringIO() + image.save(image_thumb_fp, "PNG") + except IOError: + # too bad we couldn't load the image, return the whole file :/ + return file_pointer.read() return image_thumb_fp.getvalue() else: return file_pointer.read() -- 2.6.2