From 22c082f9964975115a30c41b95ece778385d4ee1 Mon Sep 17 00:00:00 2001 From: maad-odoo Date: Wed, 1 Nov 2023 10:44:55 +0530 Subject: [PATCH] [FIX] web_editor: make heigher pillow version support Before this commit: We used the .textsize method, which returned the height and width of the icon. However, in the latest version of Pillow, this method was deprecated, resulting in errors in the log. After this commit: We have transitioned to using the textbbox method, which returns the coordinates of the top, left, bottom, and right of the text's bounding box. From these coordinates, we calculate the height and width of the text. task-3502373 closes odoo/odoo#140613 Signed-off-by: Antoine Guenet (age) --- addons/web_editor/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 0b0806b3f39..f72adff467c 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -115,7 +115,9 @@ class Web_Editor(http.Controller): image = Image.new("RGBA", (width, height), color) draw = ImageDraw.Draw(image) - boxw, boxh = draw.textsize(icon, font=font_obj) + box = draw.textbbox((0, 0), icon, font=font_obj) + boxw = box[2] - box[0] + boxh = box[3] - box[1] draw.text((0, 0), icon, font=font_obj) left, top, right, bottom = image.getbbox()