From 2475e843a041b12b75b07023e80aa239b42675df Mon Sep 17 00:00:00 2001 From: Piotr Machowski <6118709+PiotrMachowski@users.noreply.github.com> Date: Sat, 5 Aug 2023 20:08:42 +0200 Subject: [PATCH] Quickfix for HA2023.8 --- .../xiaomi_cloud_map_extractor/common/image_handler.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py b/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py index ab9414a..53f0eb5 100644 --- a/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py +++ b/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py @@ -73,7 +73,8 @@ def create_empty_map_image(colors: Colors, text: str = "NO MAP") -> ImageType: else: text_color = (255, 255, 255) draw = ImageDraw.Draw(image, "RGBA") - w, h = draw.textsize(text) + l, t, r, b = draw.textbbox((0, 0), text) + w, h = r - l, b - t draw.text(((image.size[0] - w) / 2, (image.size[1] - h) / 2), text, fill=text_color) return image @@ -256,7 +257,7 @@ def draw_func(draw: ImageDraw): point = position.to_img(image.dimensions) angle = -position.a if position.a is not None else 0 coords = [point.x - r, point.y - r, point.x + r, point.y + r] - draw.pieslice(coords, angle + 90, angle - 90, outline="black", fill=fill) + draw.pieslice(coords, angle + 90, angle - 90, outline=outline, fill=fill) ImageHandler.__draw_on_new_layer__(image, draw_func, 1, ImageHandler.__use_transparency__(outline, fill)) @@ -303,7 +304,8 @@ def draw_func(draw: ImageDraw): except ImportError: _LOGGER.warning("Unable to open font: %s", font_file) finally: - w, h = draw.textsize(text, font) + l, t, r, b = draw.textbbox((0, 0), text, font) + w, h = r - l, b - t draw.text((x - w / 2, y - h / 2), text, font=font, fill=color) ImageHandler.__draw_on_new_layer__(image, draw_func, 1, ImageHandler.__use_transparency__(color))