From 11efb2c2eb1e235fc9aa5f3e6cc6dab833877b21 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 5 Nov 2019 05:43:36 -0500 Subject: [PATCH] Avoid drawing image_processing font text inside the bow line (#27796) * Adjust font text such that it won't be drawn inside the bow line in image_processing.draw_box * Adjust font_height after actually counting the pixels * Thinned out line_width and adjusted font size --- homeassistant/components/image_processing/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/image_processing/__init__.py b/homeassistant/components/image_processing/__init__.py index e9621fe6bbe..4c90441e7f0 100644 --- a/homeassistant/components/image_processing/__init__.py +++ b/homeassistant/components/image_processing/__init__.py @@ -85,7 +85,8 @@ def draw_box( the bounding box will be `(40, 10)` to `(180, 50)` (in (x,y) coordinates). """ - line_width = 5 + line_width = 3 + font_height = 8 y_min, x_min, y_max, x_max = box (left, right, top, bottom) = ( x_min * img_width, @@ -99,7 +100,9 @@ def draw_box( fill=color, ) if text: - draw.text((left + line_width, abs(top - line_width)), text, fill=color) + draw.text( + (left + line_width, abs(top - line_width - font_height)), text, fill=color + ) async def async_setup(hass, config):