diff --git a/backend/open_webui/models/users.py b/backend/open_webui/models/users.py index b8f688a..61262d7 100644 --- a/backend/open_webui/models/users.py +++ b/backend/open_webui/models/users.py @@ -346,7 +346,11 @@ class UsersTable: users = db.query(User).filter(User.id.in_(user_ids)).all() return [user.id for user in users] - def generate_image_base64(letter, size=(200, 200)): + def generate_image_base64(letter, size=200): + # Upewniamy się, że size jest krotką + if isinstance(size, int): + size = (size, size) + # Tworzenie obrazu z losowym kolorem tła background_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) image = Image.new('RGB', size, color=background_color) @@ -356,7 +360,11 @@ class UsersTable: # Ładowanie czcionki font_size = min(size) // 2 - font = ImageFont.truetype("arial.ttf", font_size) + try: + font = ImageFont.truetype("arial.ttf", font_size) + except IOError: + # Jeśli nie ma czcionki Arial, użyj domyślnej + font = ImageFont.load_default() # Obliczanie pozycji tekstu text_width, text_height = draw.textsize(letter, font=font)