mod letter
This commit is contained in:
parent
e4ed8a0cbd
commit
104a6e5713
|
|
@ -346,7 +346,11 @@ class UsersTable:
|
||||||
users = db.query(User).filter(User.id.in_(user_ids)).all()
|
users = db.query(User).filter(User.id.in_(user_ids)).all()
|
||||||
return [user.id for user in users]
|
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
|
# Tworzenie obrazu z losowym kolorem tła
|
||||||
background_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
|
background_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
|
||||||
image = Image.new('RGB', size, color=background_color)
|
image = Image.new('RGB', size, color=background_color)
|
||||||
|
|
@ -356,7 +360,11 @@ class UsersTable:
|
||||||
|
|
||||||
# Ładowanie czcionki
|
# Ładowanie czcionki
|
||||||
font_size = min(size) // 2
|
font_size = min(size) // 2
|
||||||
|
try:
|
||||||
font = ImageFont.truetype("arial.ttf", font_size)
|
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
|
# Obliczanie pozycji tekstu
|
||||||
text_width, text_height = draw.textsize(letter, font=font)
|
text_width, text_height = draw.textsize(letter, font=font)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue