Skip to content

Sateviss/braillify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

braillify

Converts images to braille patterns

Requirements

Requires Python 3.6+ to run

Running

To download the program, create a virtual enviorment and install required packages run this:

git clone https://github.com/Sateviss/braillify
cd braillify
python3 -m venv venv
./venv/bin/pip3 install -r requirements.txt
chmod +x braillify.py && ./braillify.py -h

You can run the sample by running this in your terminal

./braillify.py -i sample.jpg -s=0.9 -w 60 -t

Examples

Sample

Running the sample should give you something like this:

$ ./braillify.py -i sample.jpg -s=0.9 -w 60 -t
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡿⣞⣯⣿⣻⡷⣤⣠⣤⣤⡴⣶⢶⡶⣶⢶⡶⣤⣤⣤⣴⢾⣻⣽⡷⣿⢾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣻⣟⣯⣿⣳⣿⣻⣽⣾⢷⣿⣻⣟⣿⣻⣟⣿⢯⣷⢿⡾⣿⣻⣽⣟⣿⣻⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣯⣿⣽⣾⣯⣿⡽⣟⣾⣿⡽⣯⡿⣾⣯⢿⡾⣟⣿⣻⣟⣯⡿⣷⢿⣽⣯⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⢿⡾⣷⢿⣞⣷⣯⡿⣿⣽⡾⣟⣯⣿⣻⡾⣟⣿⢿⣽⣯⣿⡽⣟⣿⣻⡷⣿⢾⣳⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣻⣯⣿⣻⣯⡿⣷⣻⡿⣽⣾⣟⣿⢯⣿⡽⣟⣿⣽⣟⣷⢿⣞⣿⣻⣽⡷⣿⣻⣟⣿⢷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣽⡾⣯⣷⢿⠝⡉⠅⠨⠀⡂⢐⠠⢉⠊⠍⠩⠑⡐⢀⠂⠡⠐⠠⢉⢙⠻⣯⣿⣽⣾⢿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⢾⣻⣯⡟⢁⠐⠠⠈⡀⡄⡀⠂⡐⢀⠂⠡⢈⠐⡀⢂⠨⢀⡠⣀⠐⠀⢂⠙⣷⡿⣾⣟⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣟⣯⣷⡇⠐⡈⠀⢰⢠⢣⡣⢀⠐⠠⢈⠐⡀⢂⠐⠠⠀⡇⡜⣜⠄⠐⢀⠂⣹⣟⣿⢾⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠄⠀⠀⠒⠂⠀⠀⠀⠀⣀⣀⡈⢿⣽⡷⣇⠂⠄⡁⠀⠳⠱⠉⠀⠌⢐⠀⡂⡐⠠⠈⠄⡁⠑⠝⠜⠀⠐⡀⠂⣿⣽⣯⠏⢀⣀⣀⠀⠀⠀⠀⠒⠂⠀⠀⠤⠀⠀
⠀⠀⠀⠐⠂⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀⠫⣿⣟⣦⡂⢐⠠⠠⠀⠄⠡⠈⠄⠂⡑⠡⡈⠄⠡⠀⡂⠠⠀⠄⠡⢀⣽⣟⡷⠋⠀⠀⠀⠀⠀⠀⠀⠈⠁⠀⠐⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠫⢿⣶⣴⣤⣁⣌⡠⢁⠂⠡⠑⠈⠄⠨⠀⢅⣐⣈⣤⣥⣾⡟⠏⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⢯⣖⣄⠀⠀⠀⠀⠀⠈⠈⠉⢙⣿⣿⢿⣿⣿⣿⣿⣿⣿⣿⡋⠉⠁⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢷⣗⣄⠀⠀⠀⠀⠀⣰⣟⣷⣟⣿⢷⡿⡾⣷⢿⣞⣯⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠳⢷⣾⣥⣶⣤⣷⣿⣽⢷⢹⣽⣟⡇⢸⣿⣻⠙⣯⣷⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⠉⠉⠁⣿⢾⣿⠰⣿⢾⡇⢸⣯⣿⠀⣿⣳⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣻⣽⢘⣿⣻⡇⣸⡿⣾⠀⣿⣽⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠄⠠⢐⠠⡿⣯⣿⢸⣯⣿⡃⣼⣟⣿⠀⣿⡾⣇⢐⢀⠂⠄⡀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡂⠅⡐⠨⠈⣤⡶⣿⠻⠡⢸⣷⣟⡇⢺⣽⢿⡀⠝⠿⣻⣦⡔⢈⢐⢀⠂⠌⡠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢂⢐⠐⡠⠁⢅⠐⠨⡠⡑⠥⡾⠷⢛⢀⢊⢛⠿⣳⠔⡑⠔⡐⠠⠁⠔⡀⢊⠐⡐⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠂⡁⡂⠌⢂⠢⡊⢌⢐⠅⢕⢐⠐⢔⠡⢂⢑⠌⡂⡂⠡⠁⠅⠐⠄⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠁⠈⠂⠂⠑⠁⠂⠘⠀⠑⠐⠐⠁⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Done in 0.104 s

Original image

In this example options used are:

  • -s=0.9 scales the image vertically by 90%
  • -w 60 sets output width to 60 characters
  • -t times execution
  • -i sample.jpg path to image on disk ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

From URL

You can also use images directly from the Internet ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

$ ./braillify.py -s=0.9 -w=40 --inv -c=1.5 -i https://images.pexels.com/photos/1809611/pexels-photo-1809611.jpeg
⠀⠀⡀⢀⢀⠠⠀⠠⠀⠄⠠⢀⠠⢀⠄⠄⡐⠀⠄⠂⠄⠂⡠⠠⠐⠠⠐⡀⠄⠄⠄⠠⠀⠄⡀⠄⢀⠠⠀⠀
⢀⠁⠄⢐⠠⢐⠈⠄⠅⢌⢐⢐⠐⠄⡂⡂⡂⢅⠊⢌⢐⠡⡐⢄⠕⡨⢐⢐⠄⠅⢌⠂⠅⡂⢂⠌⡠⢀⠂⡁
⢐⠨⠨⡐⡐⡐⢌⠌⡌⡂⢆⢪⢘⢌⠢⡢⡊⡢⡑⢕⢌⢒⢌⢆⢕⢌⠆⡕⢌⡊⡢⡑⡅⡪⡐⢌⢂⠢⡨⠠
⢰⠡⡑⡔⡑⡌⢆⢣⢊⢎⢆⢕⢜⢔⢕⢜⢔⢕⢕⢕⢜⢜⢌⢎⢖⢅⢧⢱⢱⢊⢎⡢⢕⠬⡸⡐⠥⡱⠨⡊
⢱⢡⢣⢱⢱⢸⢸⢸⢸⢸⢸⡸⡜⣜⢼⢜⢞⢎⢧⣫⡺⣜⣕⢧⢳⡱⡱⣕⣕⢵⢱⢕⢕⢕⢕⢕⢍⢎⢎⢜
⢕⢕⢕⢕⣕⢕⣕⢵⢝⣜⢮⡪⡯⣺⠕⠯⠓⠫⠳⣳⣝⢮⢮⡳⣳⡹⡕⡗⡮⢮⡳⣕⢇⡗⡵⡱⡱⡱⡱⡱
⡕⡽⡸⣕⢮⢳⣱⢳⢝⡮⣺⡺⡽⠁⠀⠀⠀⠀⠀⠈⠺⣝⢷⣝⣞⢮⣻⡪⣏⡧⡯⡮⡳⣕⣝⢎⢧⢫⡪⣪
⡝⡮⡳⣕⢗⢽⢜⡽⣕⡯⡳⠙⠀⠀⠀⠀⠀⠀⠀⠀⠀⠩⣗⣷⣫⣟⡮⣟⣞⣞⣗⡽⣕⣗⢵⡝⣎⢧⡫⣎
⣝⢮⡫⡮⡯⣫⢗⣽⡺⣎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣞⡾⣾⢽⣗⣯⣾⣺⢽⣳⢽⣳⣫⢗⡷⣝⢮
⡮⣳⣝⢽⢽⣺⢽⣺⡽⣽⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣽⢾⣻⣽⡟⠪⠅⠳⣻⣽⣞⣿⣺⣺⣝⡾⣵⣫
⡯⣞⢾⣝⣯⢾⢯⣷⣻⣽⣗⣷⣦⣤⡠⡄⠀⠀⠀⠀⠀⠿⠿⠟⣿⣷⣿⢄⠀⠀⣟⣾⣳⣷⣻⣺⢮⣷⣳⣳
⣟⢾⡽⣺⣞⣯⣿⣺⣟⣾⣻⣾⡷⡿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣾⣿⡌⠀⢯⣿⣽⡾⣽⣾⣻⣞⣾⣺
⡯⣗⣿⡽⣾⣳⣟⣷⣟⣯⣿⢷⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⠇⠀⣿⣻⣾⣟⣿⣞⣷⣻⣞⡾
⡿⣽⣞⣿⣽⣿⣽⣿⣽⣿⣻⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠀⣿⣟⣯⣿⣾⣻⡾⣗⣯⣿
⣟⣷⣟⣷⡿⣾⡿⣾⣟⣿⣿⣻⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⢿⣿⣾⣟⣿⣿⣽⣾
⣿⢷⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⡿⣟⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠀⢰⣤⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣗⣿⢝⣻⢿⢿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣾⣝⣞⡻⣷⣽⣿⣿⣿⣿⣻⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠁⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣻⣟⣦⡛⠷⡿⣿⢧⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣚⢳⠍⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠁⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡜⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡂⠄⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠻⠛⢛⠿⠿⡿⡿⠟⠿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⠀⠁⠈⠀⠁⠁⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠿⠛⠻⠻⠛⠟⠏⠟⠻⡹⢽
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠨⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Original image

In this example options used are:

  • -s=0.9 scales the image vertically by 90%
  • -w=40 sets output width to 40 characters, which is not necessary, since 40 is the default value
  • --inv inverts the image, i.e. black pixels become white and vice versa
  • -c=1.5 sets image contrast to 150%
  • -i url path to image

License

Distributed under GPL 3.0, see LICENSE.txt for more information

About

Converts images to braille patterns

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages