[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
This commit is contained in:
Lucas Perais (lpe)
2018-08-27 10:31:43 +02:00
parent 3c9aa50449
commit 7768abd40b
+2
View File
@@ -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())