Convert Image/Video to ASCII art.
convert2ascii provides two executable commands:
- image2ascii: transform picture to ascii art and display in terminal.
- video2ascii: transform video to ascii art, you can save or play it in terminal.
It also provides classes as a gem:
- Convert2Ascii::Image2Ascii
- Convert2Ascii::Video2Ascii
you can use it in your code and make your own ascii art !
- MacOS 15.2 ✅
- Ubuntu 24.04 ✅
- Windows 11 ❌
- Docker ✅
- Black Myth: Wukong
- The Matrix: Neo
- Ruby 3+
- ImageMagick (Download here)
- ffmpeg (Download here)
$ docker run -it -v $(pwd):/app mark24code/convert2ascii bash -c "cd /app && exec bash"
$(pwd)
can be changed to your local path. Here, use your working path.
# image
image2ascii -i </path/to/image>
# video
video2ascii -i </path/to/video.mp4>
$ gem install convert2ascii
Convert an image to ascii art.
image2ascii -h
Usage: image2ascii [options]
--version version
-i, --image=URI image uri (required)
-w, --width=WIDTH image width (integer)
-s, --style=STYLE ascii style: 'color'/'text'
-b, --block ascii color style use BLOCK or not true/false
Convert a video to ascii art.
Usage: video2ascii [options]
* By default, it will generate and play without saving.
* The -p option will just play the ascii frames within the directory, and ignore -i, -o other options. --loop will play loop
* -i,-o will just generate and output frames and ignore others options
--version version
-i, --input=URI video uri (required)
-w, --width=WIDTH video width (integer)
-s, --style=STYLE ascii style: ['color'| 'text']
-b, --block ascii color style use BLOCK or not [ true | false ]
-o, --ouput=OUTPUT save ascii frames to the output directory
-p, --play_dir=PLAY_DIRNAME input the ascii frames directory to play
--loop
require 'convert2ascii/image2ascii'
# generate image
uri = "path/to/image"
ascii = Convert2Ascii::Image2Ascii.new(uri:, width: 50)
# generate image
ascii.generate
# display in your terminal
ascii.tty_print
# also chain call
ascii.generate.tty_print
require 'convert2ascii/video2ascii'
# generate video
uri = "path/to/video.mp4"
ascii = Convert2Ascii::Video2Ascii.new(uri:, width: 50)
# generate video
ascii.generate
# save frames
ascii.save(output_path)
# play in terminal
ascii.play
# chain call
ascii.generate.play