diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 2203da37d00..f6fabd48ac7 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -13,6 +13,7 @@ from PIL import Image, ImageFont, ImageDraw from lxml import etree from base64 import b64decode, b64encode from datetime import datetime +from math import floor from odoo.http import request, Response from odoo import http, tools, _, SUPERUSER_ID @@ -112,6 +113,13 @@ class Web_Editor(http.Controller): bg = bg.replace('rgba', 'rgb') bg = ','.join(bg.split(',')[:-1])+')' + # Convert the opacity value compatible with PIL Image color (0 to 255) + # when color specifier is 'rgba' + if color is not None and color.startswith('rgba'): + *rgb, a = color.strip(')').split(',') + opacity = str(floor(float(a) * 255)) + color = ','.join([*rgb, opacity]) + ')' + # Determine the dimensions of the icon image = Image.new("RGBA", (width, height), color) draw = ImageDraw.Draw(image)