[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) <age@odoo.com>
This commit is contained in:
committed by
Antoine Guenet
parent
16251091dc
commit
22c082f996
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user