Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
571 B
2
Indexable
Never
from PIL import Image
with Image.open("dog.png") as im:
    im = im.resize((48, 48)).convert("L")
    w, h = im.size
    for y in range(h):
        row = ""
        for x in range(w):
            pix = im.getpixel((x, y))
            if pix <= 30:
                row += "##"
            elif pix <= 70:
                row += "**"
            elif pix <= 100:
                row += "||"
            elif pix <= 150:
                row += "^^"
            elif pix <= 200:
                row += "''"
            else:
                row += "  "
        print(row)