diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-08-24 14:31:45 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-08-27 10:31:43 +0200 |
| commit | 7768abd40bb6c58bafc9397dbf2cf6ba9dadc1cc (patch) | |
| tree | 56ec832d9ebd68d97e939ef45258a1b19a0e1796 /odoo/tools/image.py | |
| parent | 3c9aa50449681efc5b4bcc680a6200c964d45804 (diff) | |
[FIX] tools:image: reset stream on crop
When cropping the image with a size, we crop it first and then we make a thumbnail out of it
Before this commit, the same byte stream was used, meaning that the thumbnail was
appended to the original
After this commit, we reset the stream
OPW 1876496
closes #26575
Diffstat (limited to 'odoo/tools/image.py')
| -rw-r--r-- | odoo/tools/image.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/odoo/tools/image.py b/odoo/tools/image.py index 24da52b3c81..2b1cbed1860 100644 --- a/odoo/tools/image.py +++ b/odoo/tools/image.py @@ -201,6 +201,8 @@ def crop_image(data, type='top', ratio=False, size=None, image_format="PNG"): raise ValueError('ERROR: invalid value for crop_type') if size: thumbnail = Image.open(io.BytesIO(output_stream.getvalue())) + output_stream.truncate(0) + output_stream.seek(0) thumbnail.thumbnail(size, Image.ANTIALIAS) thumbnail.save(output_stream, image_format) return base64.b64encode(output_stream.getvalue()) |
