[FIX] tools.image: added an image conversion before sharpening; otherwise the filter could crash.

bzr revid: tde@openerp.com-20120913113655-t5o3wk3r0tkp203m
This commit is contained in:
Thibault Delavallée
2012-09-13 13:36:55 +02:00
parent 73ea18f9ed
commit fd4b83e8d1
+2 -1
View File
@@ -66,8 +66,9 @@ def image_resize_image(base64_source, size=(1024, 1024), encoding='base64', file
# check image size: do not create a thumbnail if avoiding smaller images
if avoid_if_small and image.size[0] <= size[0] and image.size[1] <= size[1]:
return base64_source
# create a thumbnail: will resize and keep ratios
# create a thumbnail: will resize and keep ratios, then sharpen for better looking result
image.thumbnail(size, Image.ANTIALIAS)
image.convert('RGB')
image = image.filter(ImageFilter.SHARPEN)
# create a transparent image for background
background = Image.new('RGBA', size, (255, 255, 255, 0))