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=35
docker run
tells docker to run an application.-t
allocates a pseudo-TTY.--rm
makes sure to remove the container when it exits-v
bind mounts a volume, and in this case we're telling docker to bind our working directory ($(pwd)
) to/app
within the container.talinx/jp2a
is 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-depth
flag whereas the original does not.file.ext
is 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=4
tellsjp2a
to output 4 colors. You can adjust this if necessary, but it's good to limit the color depth to better suitneofetch
for example.--width=35
character 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.py
file in the working directory - Run a
jp2a
command 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 7
You 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)
jp2a
can 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