-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_showcase.py
36 lines (29 loc) · 1.01 KB
/
generate_showcase.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
This module provides a function to create and save an image with custom text,
and background colors using the Pillow library.
"""
from PIL import Image, ImageDraw, ImageFont
TEXT = """ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789
_-~=+*&#$@%^
/<[{(|)}]>\
`'".,:;!?"""
WIDTH, HEIGHT = 3840, 1350
FONT_PATH = "NeoSpleen.ttf"
FONT_SIZE = 294
FONT = ImageFont.truetype(FONT_PATH, FONT_SIZE)
def create_image(text_color, background_color, file_path):
"""
Create an save an image with specified text color and background color.
Args:
text_color (str): The color of the text in the image.
background_color (str): The background color of the image.
file_path (str): The filename to save the image under.
"""
image = Image.new("RGB", (WIDTH, HEIGHT), background_color)
draw = ImageDraw.Draw(image)
draw.text((0, 0), TEXT, fill=text_color, font=FONT)
image.save("Showcase-" + file_path)
create_image("white", "black", "WoB.png")
create_image("black", "white", "BoW.png")