-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASCCI.py
More file actions
35 lines (32 loc) · 1.21 KB
/
Copy pathASCCI.py
File metadata and controls
35 lines (32 loc) · 1.21 KB
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
from PIL import Image
from random import randint
back_image = Image.open("ayo.webp")#input background
back_image = back_image.convert("HSV")
back_image = Image.Image.resize(back_image,size=[100,100])
back_image_pixels = back_image.load()
listt = []
for y in range(0,back_image.size[0]):
listappend = []
for x in range(0,back_image.size[1]):
if x == 0 and y==0:
hsv_bounds = back_image_pixels[x,y]
bright_lower_1 = hsv_bounds[2]-40
bright_higher_1 = hsv_bounds[2]+30
bright_higher_2 = hsv_bounds[2]+80
if back_image_pixels[x,y][2] > bright_lower_1 and back_image_pixels[x,y][2] < bright_higher_1:
listappend.append("/")
elif back_image_pixels[x,y][2] <= bright_lower_1:
listappend.append(".")
elif back_image_pixels[x,y][2] >= bright_higher_1 and back_image_pixels[x,y][2] < bright_higher_2:
listappend.append("#")
else:
listappend.append("@")
listt.append(listappend)
file = open("asciiview.txt", "w")
for i in range(0,len(listt)):
cur_string = ""
for x in range(0,len(listt[i])):
cur_string+=listt[i][x]
file.write(cur_string)
file.write("\n")
file.close()