Last active
January 7, 2020 15:30
-
-
Save WitherOrNot/5512f02546e790af94d84f5b5e004241 to your computer and use it in GitHub Desktop.
images for blind people and youtube commenters
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
# -*- coding: utf-8 -*- | |
from PIL import Image | |
import sys | |
THRESH = int(sys.argv[2]) if len(sys.argv) > 2 else 200 | |
col = Image.open(sys.argv[1]) | |
col.thumbnail((128, 128), Image.ANTIALIAS) | |
w, h = col.size | |
if w%6 != 0 or h%6 != 0: | |
wgap = (6-(w%6))%6 | |
print(wgap) | |
hgap = (6-(h%6))%6 | |
print(hgap) | |
col = col.resize((w+wgap, h+hgap), Image.ANTIALIAS) | |
w, h = col.size | |
gray = col.convert('L') | |
bw = gray.point(lambda x: 255 if x>THRESH else 0, '1') | |
bw.save("result_bw.png") | |
braille = "" | |
bdata = " A1B'K2L@CIF/MSP\"E3H9O6R^DJG>NTQ,*5<-U8V.%[$+X!&;:4\\0Z7(_?W]#Y)=" | |
truebraille = u"⠀⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿" | |
for j in range(h)[::3]: | |
for i in range(w)[::2]: | |
cr = bw.crop((i, j, i+2, j+3)) | |
cd = [1-(x/255) for x in list(cr.getdata())] | |
cd = (int(''.join([str(x) for x in cd[0::2]+cd[1::2]][::-1]),2)) | |
cd = truebraille[cd] | |
braille += cd | |
braille += "\n" | |
out = open("braille.txt","wb") | |
out.write(braille.encode('utf8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠶⠶⠿⠟⠛⠻⠷⠶⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠴⠿⠛⠉⠁⠀⠀⠀⠀⠀⠙⠿⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠴⠿⠋⠀⠀⠀⠀⠀⠀⠐⠦⠄⠀⠈⠿⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠠⠾⠟⠁⠀⠀⠀⠀⠀⠤⠀⠀⠈⠿⠆⠀⠹⠷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠾⠏⠀⠀⠀⠀⠀⠀⠀⠉⠻⠦⠀⠘⠿⠄⠸⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠴⠶⠾⠿⠿⠿⠿⠿⠿⠷⠶⠤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠸⠟⠀⠀⠀⠀⠐⠶⠤⠀⠀⠈⠿⠦⠴⠿⠿⠿⠿⠦⠀⠀⠀⠀⠀⠀⠤⠶⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠿⠇⠀⠀⠀⠀⠀⠀⠹⠷⠄⠀⠾⠟⠋⠁⠀⠀⠈⠻⠧⠀⠀⠠⠶⠿⠿⠿⠿⠿⠿⠿⠿⠋⠉⠀⠤⠀⠈⠉⠻⠿⠿⠿⠿⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠿⠀⠀⠀⠀⠤⠀⠀⠀⠹⠷⠾⠏⠀⠀⠀⠀⠀⠀⠸⠿⠤⠾⠿⠿⠿⠿⠿⠿⠿⠿⠟⠁⠠⠶⠟⠙⠧⠠⠴⠆⠈⠿⠿⠿⠿⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠿⠀⠀⠀⠠⠇⠀⠀⠀⠀⠿⠿⠀⠀⠀⠀⠀⠀⠀⠸⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠧⠤⠬⠅⠀⠀⠈⠉⠀⠿⠄⠘⠿⠿⠿⠿⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠿⠆⠀⠀⠈⠿⠀⠀⠀⠀⠿⠿⠦⠤⠤⠴⠊⠀⠀⠾⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠶⠦⠄⠸⠓⠀⠿⠿⠿⠿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠹⠧⠀⠀⠀⠙⠷⠦⠤⠾⠟⠉⠙⠛⠋⠁⠀⠀⠼⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠶⠄⠴⠿⠿⠿⠿⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠻⠦⠀⠀⠀⠈⠉⠋⠉⠀⠀⠀⠀⠀⠀⠠⠾⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠟⠛⠻⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠻⠷⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠴⠿⠿⠿⠿⠿⠿⠿⠁⠀⠈⠙⠁⠀⠀⠀⠙⠯⠀⠀⠉⠙⠻⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠿⠏⠛⠶⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠿⠉⠻⠿⠿⠿⠀⠀⠀⠀⠴⠛⠋⠛⠆⠉⠀⠀⠀⠀⠠⠾⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠿⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠾⠇⠄⠼⠿⠿⠿⠀⠀⠀⠾⠁⠀⠤⠦⠽⠄⠀⠀⠀⠀⠋⠉⠉⠉⠙⠿⠿⠿⠿⠿⠿⠿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠻⠷⠄⠀⠀⠀⠀⠀⠀⠀⠀⠠⠴⠿⠏⠀⠻⠿⠿⠿⠿⠀⠀⠸⠃⠀⠞⠡⠶⠽⠇⠀⠀⠀⠠⠶⠛⠛⠦⠀⠻⠿⠿⠿⠿⠿⠿⠿⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⠷⠶⠶⠶⠶⠶⠶⠿⠿⠿⠿⠧⠀⠾⠿⠿⠿⠟⠀⠀⠿⠀⠸⠡⠿⠉⠿⠁⠀⠀⠰⠟⠁⠲⠄⠘⠇⠈⠻⠿⠿⠿⠿⠿⠿⠧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠀⠿⠿⠿⠡⠶⠆⠀⠻⠀⠸⠼⠿⠿⠿⠶⠦⠤⠿⠟⠿⠄⠇⠀⠿⠀⠀⠉⠉⠿⠿⠿⠿⠿⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠷⠿⠛⠡⠿⠿⠷⠄⠈⠷⠟⠉⠀⠀⠀⠀⠉⠛⠿⠶⠿⠁⠇⠠⠏⠀⠀⠀⠠⠿⠿⠿⠿⠿⠧⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠾⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠃⠀⠸⠿⠿⠿⠿⠶⠿⠁⠀⠀⠀⠀⠀⠀⠀⠈⠿⠏⠜⠀⠼⠁⠀⠀⠠⠾⠿⠿⠿⠿⠿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠇⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠀⠀⠀⠙⠿⠿⠿⠿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠯⠠⠞⠁⠀⠀⠴⠿⠿⠿⠿⠿⠟⠘⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠰⠿⠇⠸⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠧⠀⠀⠀⠀⠿⠿⠿⠿⠿⠄⠀⠀⠀⠀⠀⠀⠀⠀⠠⠿⠉⠀⠀⠠⠀⠿⠿⠿⠿⠉⠛⠿⠆⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠸⠿⠇⠀⠻⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠀⠀⠀⠀⠙⠿⠿⠿⠿⠿⠦⠀⠀⠀⠀⠀⠀⠀⠼⠷⠶⠶⠶⠿⠇⠼⠿⠿⠿⠤⠀⠸⠿⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠸⠿⠇⠀⠈⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠇⠀⠀⠀⠀⠀⠿⠹⠿⠿⠿⠿⠶⠶⠤⠴⠶⠿⠿⠿⠿⠿⠿⠿⠇⠿⠿⠿⠋⠀⠀⠸⠿⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠿⠇⠀⠀⠘⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠄⠀⠀⠀⠀⠿⠦⠙⠛⠛⠛⠻⠿⠿⠿⠿⠿⠿⠿⠿⠟⠛⠋⠀⠿⠟⠋⠀⠀⠀⠼⠿⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠧⠀⠀⠀⠹⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠄⠀⠀⠀⠿⠿⠿⠶⠤⠀⠈⠛⠿⠿⠛⠿⠿⠿⠟⠁⠀⠀⠀⠿⠃⠀⠀⠀⠴⠿⠳⠿⠃⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⠿⠀⠀⠀⠀⠻⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠆⠀⠀⠻⠿⠿⠿⠿⠿⠷⠶⠦⠤⠾⠋⠈⠀⠀⠀⠀⠀⠰⠿⠀⠀⠤⠾⠟⠁⠼⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⠇⠀⠀⠀⠀⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠄⠀⠈⠿⠿⠿⠿⠿⠿⠿⠿⠿⠃⠀⠀⠀⠀⠀⠀⠴⠿⠿⠿⠿⠟⠋⠀⠀⠿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⠿⠀⠀⠀⠠⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠷⠄⠀⠈⠻⠿⠿⠿⠿⠟⠋⠁⠀⠀⠀⠀⠀⠤⠾⠟⠃⠀⠀⠀⠀⠀⠀⠼⠿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠿⠧⠀⠀⠾⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠦⠄⠀⠈⠉⠉⠁⠀⠀⠤⠶⠶⠶⠾⠿⠟⠉⠀⠀⠀⠀⠀⠀⠀⠠⠿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⠆⠸⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠷⠶⠦⠴⠶⠶⠿⠿⠿⠿⠿⠿⠿⠿⠦⠀⠀⠀⠀⠀⠀⠠⠿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⠿⠿⠿⠿⠿⠿⠿⠛⠻⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠷⠄⠀⠀⠀⠠⠾⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⠿⠿⠿⠿⠟⠁⠀⠀⠹⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠷⠄⠀⠠⠿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠿⠿⠿⠟⠀⠀⠀⠶⠸⠿⠿⠿⠿⠿⠿⠟⠛⠻⠿⠟⠛⠉⠉⠉⠉⠉⠉⠛⠻⠿⠿⠿⠿⠷⠴⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⠧⠀⠠⠼⠃⠾⠿⠿⠿⠿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠿⠿⠿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⠷⠮⠴⠾⠿⠿⠿⠿⠿⠏⠀⠀⠀⠠⠀⠀⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠠⠾⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⠿⠿⠿⠿⠿⠿⠃⠀⠀⠀⠟⠀⠀⠰⠇⠀⠀⠸⠀⠀⠀⠀⠾⠟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⠿⠿⠿⠆⠀⠀⠸⠇⠀⠀⠸⠇⠀⠀⠿⠀⠀⠀⠀⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠻⠷⠤⠴⠿⠧⠀⠀⠿⠇⠀⠀⠻⠄⠀⠀⠀⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠋⠙⠿⠀⠀⠸⠇⠀⠀⠘⠷⠄⠀⠰⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⠧⠀⠈⠿⠦⠀⠰⠿⠛⠛⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⠿⠟⠛⠿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀