To convert an image to ASCII art, use jp2a. I found that using the Docker image was the most portable way to do this, especially as it doesn't require you to build the binary manually.
docker run -t --rm -v "$(pwd)":/app talinx/jp2a file.ext --color-depth=4 --width=35docker runtells docker to run an application.-tallocates a pseudo-TTY.--rmmakes sure to remove the container when it exits-vbind mounts a volume, and in this case we're telling docker to bind our working directory ($(pwd)) to/appwithin the container.talinx/jp2ais the docker image. You can find it here on Docker Hub. The GitHub repo may also be a valuable resource. Note: The linked repo is a fork, and that's the one we want to use. This is because that fork has the--color-depthflag whereas the original does not.file.extis the image file you want to convert. Note: This file must be placed in the working directory, otherwise the container will not be able to find it, as described in the 4th bullet point.--color-depth=4tellsjp2ato output 4 colors. You can adjust this if necessary, but it's good to limit the color depth to better suitneofetchfor example.--width=35character width of the resulting ASCII art.
This Python script can be used in conjunction with jp2a to create an ASCII text file for neofetch with colors.
- Create
jp2a2neofetch.pyfile in the working directory - Run a
jp2acommand and pipe it to the Python script, then save the output to a text file
docker run -t --rm -v "$(pwd)":/app talinx/jp2a file.ext --color-depth=4 --width=35 | python3 ./jp2a2neofetch.py > output.ascii- Test the result with
neofetch
neofetch --ascii output.ascii --ascii_colors 1 4 5 6 7You can edit line 6 in jp2a2neofetch.py and the above example command to change the ASCII colors used.
When satisfied with the result, you can add the output.ascii to your neofetch config.conf file.
image_backend="ascii"
image_source="/path/to/output.ascii"
ascii_colors=(1 4 5 6 7)jp2acan be configured extensively to create ASCII art just the way you want it, make sure to check the man page for more info.
- cslarsen and Talinx for jp2a
- OpenBagTwo for the jp2a2neofetch.py script
- neofetch