random terminal art
September 8, 2025
Transforming images into pixel art, and then into ansi escape sequence codes
This project was to make little pixel sprites of characters from my favourite shows, and other images I like, display randomly whenever I open up my terminal.
It was inspired by this python script that prints a random pokemon. I'm not a huge pokemon fan, but I love the idea behind it so here I have made my own art files and my own version of a much simpler bash script to suit my needs.
First things first is resizing your images. I've found a good height for me is 50 pixels. It's important to utilize a Bicubic Nearest Neighbour algorithm when resizing, as this prevents the blur/semi-transparency you get with normal resizing.
See here the blurred pixels
Left: Normal resizing
Center: Bicubic Nearest Neighbour
Right:Original
Interestingly I discovered that krita has a built in python interpreter. I was able to utilize this to write a short script that does the resizing, and 'save as', automatically. This was a big time saver, as the idea here is to have a huge catalog of pixel characters.
next I use this python script I found online that converts the image into ansi escape sequence codes and then writes it to a file, Now it is ready to be printed to my terminal by the main script
The bash script is super simple. It chooses a random file within the directory, displays it with 'cat', and then takes the files path and cuts off the first characters to leave only franchise/character_name to be displayed underneath.
--END OF TRANSMISSION--