vertical text generator into function
All checks were successful
Upload release / build (push) Successful in 7s
All checks were successful
Upload release / build (push) Successful in 7s
This commit is contained in:
parent
a19353f869
commit
0a790e8a75
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
|
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]]):
|
def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
|
||||||
"""Generate horoscope images"""
|
"""Generate horoscope images"""
|
||||||
img_width, img_height = 1200, 425
|
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)
|
image.paste(sign_image, (x + 20, y), sign_image)
|
||||||
|
|
||||||
# Sign text
|
# Sign text
|
||||||
text_img = Image.new("RGBA", (135, 24), (255, 255, 255, 0))
|
text_draw = vertical_text(sign, font_sign)
|
||||||
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)
|
|
||||||
image.paste(text_draw, (x - 10, y - 10), text_draw)
|
image.paste(text_draw, (x - 10, y - 10), text_draw)
|
||||||
|
|
||||||
# Love prediction
|
# Love prediction
|
||||||
|
|
Loading…
Reference in a new issue