vertical text generator into function
This commit is contained in:
parent
a19353f869
commit
1052fe9e53
1 changed files with 12 additions and 4 deletions
16
main.py
16
main.py
|
@ -58,6 +58,17 @@ def get_sign_image(image: str):
|
|||
return enhanced_image
|
||||
|
||||
|
||||
def vertical_text(text: str, font: ImageFont.ImageFont | ImageFont.FreeTypeFont):
|
||||
"""Image with vertical text"""
|
||||
text_img = Image.new("RGBA", (135, 24), (255, 255, 255, 0))
|
||||
|
||||
text_draw = ImageDraw.Draw(text_img)
|
||||
text_draw.text((0, 0), f"{text:^15}", font=font, fill="black")
|
||||
text_draw = text_img.rotate(90, expand=True)
|
||||
|
||||
return text_draw
|
||||
|
||||
|
||||
def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
|
||||
"""Generate horoscope images"""
|
||||
img_width, img_height = 1200, 425
|
||||
|
@ -75,10 +86,7 @@ def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
|
|||
image.paste(sign_image, (x + 20, y), sign_image)
|
||||
|
||||
# Sign text
|
||||
text_img = Image.new("RGBA", (135, 24), (255, 255, 255, 0))
|
||||
text_draw = ImageDraw.Draw(text_img)
|
||||
text_draw.text((0, 0), f"{sign:^15}", font=font_sign, fill="black")
|
||||
text_draw = text_img.rotate(90, expand=True)
|
||||
text_draw = vertical_text(sign, font_sign)
|
||||
image.paste(text_draw, (x - 10, y - 10), text_draw)
|
||||
|
||||
# Love prediction
|
||||
|
|
Loading…
Reference in a new issue