-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,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 | ||
TEXT = """ABCDEFGHIJKLMNOPQRSTUVWXYZ | ||
abcdefghijklmnopqrstuvwxyz | ||
0123456789 | ||
_-~=+*&#$@%^ | ||
/<[{(|)}]>\ | ||
`'".,:;!?""" | ||
|
||
width, height = 3840, 1350 | ||
font_path = "NeoSpleen.ttf" | ||
font_size = 294 | ||
font = ImageFont.truetype(font_path, font_size) | ||
WIDTH, HEIGHT = 3840, 1350 | ||
FONT_PATH = "NeoSpleen.ttf" | ||
FONT_SIZE = 294 | ||
FONT = ImageFont.truetype(FONT_PATH, FONT_SIZE) | ||
|
||
|
||
def create_image(background_color, text_color, file_name): | ||
image = Image.new("RGB", (width, height), background_color) | ||
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_name) | ||
draw.text((0, 0), TEXT, fill=text_color, font=FONT) | ||
image.save("Showcase-" + file_path) | ||
|
||
|
||
create_image("black", "white", "WoB.png") | ||
create_image("white", "black", "BoW.png") | ||
create_image("white", "black", "WoB.png") | ||
create_image("black", "white", "BoW.png") |