from PIL import Image
q = input("Название картинки: ")
img = Image.open(q)
img = img.convert("RGB")
file = open("img.txt","w")
x = 0
y = 0
(w,h) = img.size
print(w*h)
for i in range(w*h):
r,g,b = img.getpixel((x,y))
if r == 0 and g == 0 and b == 0:
file.write("#")
else:
file.write("_")
x+=1
if x > w - 1:
y+=1
x=0
file.write("\n")
file.close()
print(img.getpixel((0,0)))
input("Enter что-бы завершить: ")
from PIL import Image
q = input("Название картинки: ")
img = Image.open(q)
img = img.convert("RGB")
(w,h) = img.size
print(w*h)
with open("img.txt","w") as file:
for y in range(h):
for x in range(w):
r, g, b = img.getpixel((x,y))
file.write("#" if (r, g, b) == (0, 0, 0) else "_")
file.write("\n")
print(img.getpixel((0,0)))
input("Enter что-бы завершить: ")