From c8d09167fdb44b6fb824705d3d9103903edc23ee Mon Sep 17 00:00:00 2001 From: fw-bot Date: Wed, 25 Sep 2019 14:59:05 +0000 Subject: [PATCH] [FIX] tools: crop & resize image crashes - When trying to access an image that need to be resized and cropped, the code could crashes. This is due to the fact that PIL expect to work with integer for sizes, but in some cases we provide floats closes odoo/odoo#37442 Signed-off-by: Toufik Benjaa (tbe) --- odoo/tools/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/tools/image.py b/odoo/tools/image.py index 5819b8c7b10..999b5c1e5e7 100644 --- a/odoo/tools/image.py +++ b/odoo/tools/image.py @@ -215,8 +215,8 @@ class ImageProcess(): new_w, new_h = (new_w * h) // new_h, h # Correctly place the center of the crop. - x_offset = (w - new_w) * center_x - h_offset = (h - new_h) * center_y + x_offset = int((w - new_w) * center_x) + h_offset = int((h - new_h) * center_y) if new_w != w or new_h != h: self.image = self.image.crop((x_offset, h_offset, x_offset + new_w, h_offset + new_h))