diff --git a/debian/control b/debian/control
index 52a3fee8d..d60fff257 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,7 @@ X-Python-Version: 2.7
Package: wcs
Architecture: all
-Depends: ${python:Depends}, python-quixote, python-scgi, graphviz, python-feedparser
+Depends: ${python:Depends}, python-quixote, python-scgi, graphviz, python-feedparser, python-imaging
Recommends: python-dns, python-m2crypto, python-xlwt, python-qrcode, libjs-leaflet
Suggests: libapache2-mod-scgi | libapache-mod-scgi, python-libxml2, python-lasso, python-psycopg2
Description: web application to design and set up online forms
diff --git a/wcs/forms/root.py b/wcs/forms/root.py
index d52523239..8b10f09a7 100644
--- a/wcs/forms/root.py
+++ b/wcs/forms/root.py
@@ -20,6 +20,11 @@ from StringIO import StringIO
import sys
import urllib2
+try:
+ from PIL import Image
+except ImportError:
+ Image = None
+
try:
import qrcode
except ImportError:
@@ -908,7 +913,15 @@ class FormPage(Directory):
if tempfile['charset']:
response.set_charset(tempfile['charset'])
- return get_session().get_tempfile_content(t).get_file_pointer().read()
+ 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")
+ return image_thumb_fp.getvalue()
+ else:
+ return file_pointer.read()
def validating(self, data):
self.html_top(self.formdef.name)
diff --git a/wcs/qommon/form.py b/wcs/qommon/form.py
index 62a14dda8..d8ea155bd 100644
--- a/wcs/qommon/form.py
+++ b/wcs/qommon/form.py
@@ -599,9 +599,8 @@ class FileWithPreviewWidget(CompositeWidget):
elif temp:
filetype = mimetypes.guess_type(temp.get('orig_filename', ''))
if filetype and filetype[0] and filetype[0].startswith('image'):
- r += htmltext('' % \
- (temp.get('orig_filename', ''),
- self.get('token')))
+ r += htmltext('' % \
+ self.get('token'))
r += htmltext('')
return r.getvalue()