This is a script for me to generate video thumbnails for none video publications. I am way to lazy to create thumbnails so this just does it automaticly.
# Python image processing imports. Handling text and other things.
from PIL import Image, ImageDraw, ImageFont
# This if for text wrapping. Using \n isn't supported in PIL text
# stuff.
import textwrap
In a directory I store background.png
here I just open it so I can manipulate it.
# Image open and draw
= Image.open("background.png")
image = ImageDraw.Draw(image) draw
Ask for input, run it through text wrap, specify a font I have in the directory and finally put it on the image.
# Text
= input('Text: ')
text = textwrap.wrap(text, width=30)
textwrapped = ImageFont.truetype("ReemKufi-Regular.ttf", 100)
dubai 400,400), '\n'.join(textwrapped), font=dubai, fill="#EE7A2F") draw.text((
I do some manipulation on the text variable so I get a nicer file name.
= text.replace(' ', '-')+".png"
filename "PNG")
image.save(filename, image.show()
https://codeberg.org/zortazert/Python-Projects/src/branch/main/thumbnail