p3 fixes in applications

This commit is contained in:
ilvalle
2016-06-28 19:58:20 +02:00
parent 5f80300c5d
commit ea337e07d0
6 changed files with 12 additions and 19 deletions
+3 -3
View File
@@ -36,11 +36,11 @@ class RESIZE(object):
if isinstance(value, str) and len(value) == 0:
return (value, None)
from PIL import Image
import cStringIO
from io import BytesIO
try:
img = Image.open(value.file)
img.thumbnail((self.nx, self.ny), Image.ANTIALIAS)
s = cStringIO.StringIO()
s = BytesIO()
if self.padding:
background = Image.new('RGBA', (self.nx, self.ny), (255, 255, 255, 0))
background.paste(
@@ -48,7 +48,7 @@ class RESIZE(object):
((self.nx - img.size[0]) / 2, (self.ny - img.size[1]) / 2))
background.save(s, 'JPEG', quality=self.quality)
else:
img.save(s, 'JPEG', queality=self.quality)
img.save(s, 'JPEG', quality=self.quality)
s.seek(0)
value.file = s
except: