From fa39019ee1b78c02c09d591cf99ae81dcb75ccfb Mon Sep 17 00:00:00 2001 From: ThanhDodeurOdoo Date: Mon, 3 Sep 2018 18:12:59 +0200 Subject: [PATCH] [FIX] tools: image.crop_image default type fix - the image.crop_image method doesn't defaults the format to PNG anymore. Instead it uses the format of the original image and defaults to jpeg as a last resort as the save method requires a type if it is called with an image object. --- odoo/tools/image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odoo/tools/image.py b/odoo/tools/image.py index 5a7294bf07e..8dbeb9f06b1 100644 --- a/odoo/tools/image.py +++ b/odoo/tools/image.py @@ -177,7 +177,7 @@ def image_resize_image_small(base64_source, size=(64, 64), encoding='base64', fi # ---------------------------------------- # Crop Image # ---------------------------------------- -def crop_image(data, type='top', ratio=False, size=None, image_format="PNG"): +def crop_image(data, type='top', ratio=False, size=None, image_format=None): """ Used for cropping image and create thumbnail :param data: base64 data of image. :param type: Used for cropping position possible @@ -206,6 +206,7 @@ def crop_image(data, type='top', ratio=False, size=None, image_format="PNG"): new_h = h new_w = (h * w_ratio) // h_ratio + image_format = image_format or image_stream.format or 'JPEG' if type == "top": cropped_image = image_stream.crop((0, 0, new_w, new_h)) cropped_image.save(output_stream, format=image_format)