Created
April 15, 2021 19:17
-
-
Save xfgusta/f1cdedbf82a18b74ec47b17d5809d09e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from PIL import Image | |
from sys import argv, stderr | |
from os import get_terminal_size | |
if len(argv) != 2: | |
print(f'Usage: {argv[0]} <img>', file=stderr) | |
exit(1) | |
img = Image.open(argv[1]) | |
img = img.resize(get_terminal_size(), Image.ANTIALIAS).convert("RGB") | |
maxx, maxy = img.size | |
for y in range(maxy): | |
for x in range(maxx): | |
r, g, b = img.getpixel((x, y)) | |
print(f'\033[48;2;{r};{g};{b}m ', end='') | |
print() | |
print('\033[0m') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment