Enhances cover generation and updates dependencies
Adds cover generation functionality for week notes, using a background image and specified font. Updates dependencies to the latest versions, including flake8, certifi, click, identify, platformdirs, pygments, python-dotenv, requests, urllib3, and weeknotebot.
This commit is contained in:
22
generate_cover.py
Normal file
22
generate_cover.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from PIL import Image, ImageDraw, ImageFont # 👉️ Import modules from PIL
|
||||
import typer
|
||||
|
||||
|
||||
def generate_img(message: str, path: str):
|
||||
font_path = "Futura Book font.ttf" # 👉️ Font .ttf Path
|
||||
font_size = 100 # 👉️ Font Size
|
||||
img = Image.open("cover.jpg") # 👉️ Open Image
|
||||
dr = ImageDraw.Draw(img) # 👉️ Create New Image
|
||||
my_font = ImageFont.truetype(font_path, font_size) # 👉️ Initialize Font
|
||||
text_x = (img.width) // 2
|
||||
text_y = (img.height) // 2
|
||||
dr.text((text_x, text_y), message, font=my_font, fill=(255, 255, 255), anchor="mm")
|
||||
img.save("content/" + path + "/cover.png")
|
||||
|
||||
|
||||
def main(message: str, path: str):
|
||||
generate_img(message, path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
typer.run(main)
|
||||
Reference in New Issue
Block a user