This article shows how to create ASCII art by converting images in the Linux command line with the Artem app.
Every Linux enthusiast spends a significant amount of time on the command line. This time, however, we’ll look at one of the most fun parts of the Linux terminal: creating ASCII art from images.
These can be used for various purposes, for example, in SSH warning banners and welcome messages.
This is where Artem comes into the picture. Artem is a small Rust command-line tool that converts photos to ASCII art. It uses the image-rs library to read images from various image formats like PNG, JPG, GIF, WEBP, etc.
Artem tries to use truecolor by default, but if the terminal does not support truecolor, it falls back to 16 Color ANSI. However, no colors are used when an ASCII image is saved to a file.
So let me demonstrate what you can accomplish with this application.
Convert Images to ASCII in Linux Using Artem
In its simplest form, Artem’s use is perfectly straightforward. The command takes an image and returns it as an ASCII art string. For example:
On top of that, Artem has a lot to offer anyone seeking more options than simple functionality. For example, you can utilize custom ASCII characters while generating the image.
--characters option to your command to accomplish this. In addition, keep in mind that the characters should be arranged in ascending order of darkness/density.
artem tux.jpg --characters "0123456789"
Another useful feature of the application is the ability to resize the generated ASCI art. The scale here ranges from 20 to 230, with 100 being the default value.
--size option to your command to use this feature.
artem tux.jpg --size 120
--outline flag filters the specified input image to only contain an outline, which is subsequently transformed. Please keep in mind that this may not function perfectly on every image. So, select an image with a clear separation between the background and the foreground for the best results.
In addition, you may also add the
--centerY options to center the result in your terminal if necessary.
artem tux.jpg --outline --centerX
Finally, Artem provides the option to save created ASCI pictures to files. Include the
--output option in your command to achieve this.
artem tux.jpg --output myfile.txt artem tux.jpg --output myfile.html artem tux.jpg --output myfile.ans
Of course, this does not exhaust all of the application’s capabilities. For example, Artem also allows you to automatically download and convert an image from the web by using the URL address.
Visit the GitHub project website to learn more about all the options for converting an image to ASCII in the Linux terminal using Artem.
Users of Debian and all Debian-based distros like Ubuntu, Linux Mint, etc., can install Artem by downloading the most recent version of the installation
.deb file and installing it locally using the apt command.
sudo apt install ./Downloads/artem_1.1.3_amd64.deb
Arch Linux users can find the application in the distribution’s AUR repository. To install it, they need to execute:
yay -S artem-bin
Other Linux users who want to use this excellent image to ASCII converter must get the application source code and manually compile it for their Linux distro.