File size: 1,357 Bytes
8f9c6dc 980feb9 8f9c6dc 980feb9 8f9c6dc |
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 37 |
#https://github.com/Ankit404butfound/HomeworkMachine/tree/master/Image for image download
from PIL.Image import open as open_image , Image
from tkinter.simpledialog import askstring
from tkinter.filedialog import asksaveasfilename
from os import chdir
import sys
chdir(sys._MEIPASS)
def condition(cont: str) -> Image:
back = open_image("zback.png")
width,height = 50,0
for letter in cont:
if letter in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+,.-? \n":
if letter == " ":
letter = "zspace"
if letter.isupper():
letter = "c"+letter.lower()
if letter == ",":
letter = "coma"
if letter == ".":
letter = "fs"
if letter == "?":
letter = "que"
if width + 150 >= back.width:
height = height + 227
width = 50
if letter == "\n":
height += 227
width = 50
continue
cases = open_image(letter+".png")
back.paste(cases,(width,height))
width += cases.width
return back
img = condition(askstring("TEXT","Hand Written Text"))
img.show()
img.save(asksaveasfilename(filetypes=[("Image Files","*.png *jpg *jpeg *ico")],initialfile="Handwriting.png"))
|