[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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user