Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image,ImageDraw,ImageFont
- import os
- unt = 0
- rech = 0
- zeichen = ['@','#','S','%','?','!','*','+',';',':','.']
- size_300 =(1000,1000)
- filename = "imm.jpg"
- image1 = Image.open(filename)
- fn, ftext = os.path.splitext(filename)
- image1.thumbnail(size_300)
- image1 = image1.convert(mode="L")
- liste_pix = list(image1.getdata())
- width, height = image1.size
- filename = fn+"ascii"+ftext
- fnt = ImageFont.truetype('arial.ttf', 15)
- image = Image.new(mode = "RGB", size = (width*12,height*12), color = "white")
- draw = ImageDraw.Draw(image)
- for i in range(width*height):
- draw.text((rech*12,unt*12),zeichen[round(liste_pix[i]/25)], font=fnt, fill=(0,0,0))
- rech = rech +1
- if i % width == 0 and i != 0:
- rech = 0
- unt = unt+1
- image.show()
- image.save("C:/Users/Tom/Documents/Python/Python/ascii_img/"+filename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement