text in image manipulation
This commit is contained in:
parent
6e6b0a0d75
commit
6e6a4c014f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.env
|
.env
|
||||||
|
images/output/*
|
BIN
fonts/impact.ttf
Normal file
BIN
fonts/impact.ttf
Normal file
Binary file not shown.
17
main.py
17
main.py
@ -3,6 +3,8 @@ import random
|
|||||||
import ssl
|
import ssl
|
||||||
import smtplib
|
import smtplib
|
||||||
|
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.image import MIMEImage
|
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_password = os.environ.get("EMAIL_PASSWORD_2")
|
||||||
mail_receiver = "norman25.na@gmail.com"
|
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():
|
def send_email():
|
||||||
try:
|
try:
|
||||||
randis = random.randint(1000, 9999)
|
randis = random.randint(1000, 9999)
|
||||||
@ -41,4 +56,4 @@ def send_email():
|
|||||||
print("Failed to send a email")
|
print("Failed to send a email")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
send_email()
|
add_textimg("Your otp code is 3826")
|
Loading…
x
Reference in New Issue
Block a user