diff --git a/.gitignore b/.gitignore index 2eea525..5e40873 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.env \ No newline at end of file +.env +images/output/* \ No newline at end of file diff --git a/fonts/impact.ttf b/fonts/impact.ttf new file mode 100644 index 0000000..114e6c1 Binary files /dev/null and b/fonts/impact.ttf differ diff --git a/main.py b/main.py index 2f0495b..c47dc53 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,8 @@ import random import ssl import smtplib +from PIL import Image, ImageDraw, ImageFont + from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.image import MIMEImage @@ -11,6 +13,19 @@ mail_sender = "norman25.projects2@gmail.com" mail_password = os.environ.get("EMAIL_PASSWORD_2") mail_receiver = "norman25.na@gmail.com" +def add_textimg(text): + img = Image.open("images/main/black-suit.png") + draw = ImageDraw.Draw(img) + font = ImageFont.truetype("fonts/impact.ttf", 64) + text_pos_center = (img.width - draw.textlength(text, font)) // 2 + pos = (text_pos_center, 720) + text_color = (255, 255, 255) + draw.text(pos, text, fill=text_color, font=font) + + img.save("images/output/pos.png") + img.close() + + def send_email(): try: randis = random.randint(1000, 9999) @@ -41,4 +56,4 @@ def send_email(): print("Failed to send a email") print(str(e)) -send_email() \ No newline at end of file +add_textimg("Your otp code is 3826") \ No newline at end of file