Skip to content

Instantly share code, notes, and snippets.

@alirezaahani
Created November 26, 2020 18:23
Show Gist options
  • Save alirezaahani/a39a739a6be918717be479317c276b1a to your computer and use it in GitHub Desktop.
Save alirezaahani/a39a739a6be918717be479317c276b1a to your computer and use it in GitHub Desktop.
#!/bin/python3
from PIL import Image
import sys
image_src = sys.argv[1]
with Image.open(image_src) as img:
h,w = img.size
with open('main.html','w+') as fhand:
fhand.write("""
<style>
* {
font-size:1px;
font-family: monospace;
}
</style>
""")
for row in range(w):
for col in range(h):
pixel = img.getpixel((col,row))
fhand.write('<span style="color:rgb({},{},{});">#</span>'.format(pixel[0],pixel[1],pixel[2]))
fhand.write('<br>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment