0

Hello I am looking for a way to convert an image (in jpg or png) into a bitmap text file (basically an array of 1's and 0's) that represent dots for 1's and blank spaces for 0's in .txt form. Basically, I would like for the user to enter their name and create a picture that would then be converted into a bitmap file so that their names can be pixelated. Is there any packages that can do this? Thank you!

What I have so far:

from PIL import Image, ImageFont, ImageDraw  


name = input("Please enter your name: ")


font_type = ImageFont.truetype("arial.ttf", 200)

h, w = 1080, 1920
bg_colour = (255, 255, 255)
bg_image = np.dot(np.ones((h,w,3), dtype='uint8'), np.diag(np.asarray((bg_colour), dtype='uint8')))
image0 = Image.fromarray(bg_image)
draw = ImageDraw.Draw(image0)
draw.text((530, 160), text = name, font=font_type, fill= 'black', align = 'center')
image0.save('your_name.jpg')

0 Answers0