Skip to content

Instantly share code, notes, and snippets.

@xfgusta
Created April 15, 2021 19:17
Show Gist options
  • Save xfgusta/f1cdedbf82a18b74ec47b17d5809d09e to your computer and use it in GitHub Desktop.
Save xfgusta/f1cdedbf82a18b74ec47b17d5809d09e to your computer and use it in GitHub Desktop.
#!/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