[FIX] 'inline' set_image_data

bzr revid: xmo@openerp.com-20131024135730-321532upt3aq5esw
This commit is contained in:
Xavier Morel 2013-10-24 15:57:30 +02:00
parent 39fb50d43d
commit a2a3f46d72
1 changed files with 3 additions and 10 deletions

View File

@ -327,21 +327,14 @@ class Images(http.Controller):
if response.status_code == 304:
return response
return self.set_image_data(
response, record[field].decode('base64'),
fit=(int(max_width), int(max_height)))
data = record[field].decode('base64')
fit = int(max_width), int(max_height)
def set_image_data(self, response, data, fit=(maxint, maxint)):
""" Sets an inferred mime type on the response object, and puts the
provided image's data in it, possibly after resizing if requested
Returns the response object after setting its mime and content, so
the result of ``get_final_image`` can be returned directly.
"""
buf = cStringIO.StringIO(data)
# FIXME: unknown format or not an image
image = Image.open(buf)
image.load()
response.mimetype = Image.MIME[image.format]
w, h = image.size