[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) <tbe@odoo.com>
This commit is contained in:
+2
-2
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user