Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
89af320a66 | |||
a61cc02c42 | |||
0a790e8a75 | |||
a19353f869 | |||
c00060af2d |
3 changed files with 38 additions and 10 deletions
|
@ -2,8 +2,7 @@ name: Upload release
|
|||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -18,4 +17,6 @@ jobs:
|
|||
uses: akkuman/gitea-release-action@v1
|
||||
with:
|
||||
token: ${{ secrets.TOKEN }}
|
||||
name: Latest version
|
||||
tag_name: latest
|
||||
files: horoscope.bat
|
||||
|
|
|
@ -16,6 +16,9 @@ CLS
|
|||
IF ERRORLEVEL 1 (
|
||||
ECHO Installation of Python not found, installation...
|
||||
|
||||
:: Accept Winget ToT
|
||||
ECHO Y | winget list >NUL
|
||||
|
||||
:: Install Python 3.12 from MS Store
|
||||
ECHO Y | winget install -he 9NCVDN91XZQP
|
||||
|
||||
|
|
40
main.py
40
main.py
|
@ -5,7 +5,7 @@ from random import choice
|
|||
from sys import argv
|
||||
from urllib.request import urlretrieve
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from PIL import Image, ImageDraw, ImageEnhance, ImageFilter, ImageFont
|
||||
|
||||
zodiac_signs = [
|
||||
"Belier",
|
||||
|
@ -41,6 +41,34 @@ def get_path(image: str):
|
|||
return join(image_dir, f"{image.lower()}.png")
|
||||
|
||||
|
||||
def get_sign_image(image: str):
|
||||
"""Get sign image"""
|
||||
sign_image = Image.open(get_path(image)).convert("RGBA")
|
||||
|
||||
# Add thickness
|
||||
alpha = sign_image.split()[3]
|
||||
bold_mask = alpha.filter(ImageFilter.MaxFilter())
|
||||
sign_image.putalpha(bold_mask)
|
||||
|
||||
# Add contrast
|
||||
enhancer = ImageEnhance.Contrast(sign_image)
|
||||
enhanced_image = enhancer.enhance(2.0)
|
||||
|
||||
enhanced_image.thumbnail((100, 105))
|
||||
return enhanced_image
|
||||
|
||||
|
||||
def vertical_text(text: str, font: ImageFont.ImageFont | ImageFont.FreeTypeFont):
|
||||
"""Image with vertical text"""
|
||||
text_img = Image.new("RGBA", (135, 29), (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
|
||||
|
@ -54,16 +82,12 @@ def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
|
|||
|
||||
x, y = 10, 10
|
||||
for sign, prediction in horoscope.items():
|
||||
sign_image = Image.open(get_path(sign)).convert("RGBA")
|
||||
sign_image.thumbnail((100, 105))
|
||||
sign_image = get_sign_image(sign)
|
||||
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)
|
||||
image.paste(text_draw, (x - 10, y - 10), text_draw)
|
||||
text_draw = vertical_text(sign, font_sign)
|
||||
image.paste(text_draw, (x - 12, y - 10), text_draw)
|
||||
|
||||
# Love prediction
|
||||
love = Image.open(join(image_dir, "love.png")).convert("RGBA")
|
||||
|
|
Loading…
Reference in a new issue