From 1e12ebe9f85d237e8d5a14164ad665c17a99a4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 5 Sep 2021 14:40:15 +0200 Subject: [PATCH] Use new image returned by PIL.Image methods issue10703 review350531006 --- trytond/ir/avatar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trytond/ir/avatar.py b/trytond/ir/avatar.py index 350a887792..c1cc8c0616 100644 --- a/trytond/ir/avatar.py +++ b/trytond/ir/avatar.py @@ -110,13 +110,13 @@ class Avatar(ImageMixin, ResourceMixin, ModelSQL): img = Image.open(io.BytesIO(image)) width, height = img.size size = min(width, height) - img.crop(( + img = img.crop(( (width - size) // 2, (height - size) // 2, (width + size) // 2, (height + size) // 2)) if size > 2048: - img.resize((2048, 2048)) + img = img.resize((2048, 2048)) if img.mode in {'RGBA', 'P'}: img = img.convert('RGB') img.save(data, format='jpeg', optimize=True, **_params)