From 195e02e41dc68698c5adbf41d9f96695b689170f Mon Sep 17 00:00:00 2001 From: "l.gabrysiak" Date: Sun, 2 Mar 2025 14:05:36 +0100 Subject: [PATCH] mod letter --- backend/open_webui/models/users.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/backend/open_webui/models/users.py b/backend/open_webui/models/users.py index 1a7684e..0369e1b 100644 --- a/backend/open_webui/models/users.py +++ b/backend/open_webui/models/users.py @@ -355,34 +355,27 @@ class UsersTable: image = Image.new('RGB', size, color=background_color) draw = ImageDraw.Draw(image) - # Ustawienie koloru czcionki na biały text_color = (255, 255, 255) - # Funkcja do obliczania rozmiaru czcionki def get_font_size(image_size, text, target_percentage=0.8): font_size = 1 - font = ImageFont.load_default().font.copy() while True: - font.set_size(font_size) + font = ImageFont.truetype("arial.ttf", font_size) bbox = font.getbbox(text) if bbox[2] > target_percentage * image_size[0] or bbox[3] > target_percentage * image_size[1]: return font_size - 1 font_size += 1 font_size = get_font_size(size, letter) - font = ImageFont.load_default().font.copy() - font.set_size(font_size) + font = ImageFont.truetype("arial.ttf", font_size) - # Obliczanie pozycji tekstu bbox = font.getbbox(letter) text_width = bbox[2] - bbox[0] text_height = bbox[3] - bbox[1] position = ((size[0] - text_width) / 2, (size[1] - text_height) / 2) - # Rysowanie litery draw.text(position, letter, font=font, fill=text_color) - # Konwersja obrazu do base64 buffered = io.BytesIO() image.save(buffered, format="PNG") img_str = base64.b64encode(buffered.getvalue()).decode()