Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.


Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.


Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.


Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells, Featured

Convert Color Text to Images in Bash

Submitted by on December 11, 2021 – 12:14 pm

The textmg is a cool little CLI tool written by jiro4989 – a systems engineer from Japan – that allows you to convert the color output in a terminal window to an image file. I find this very useful when sharing code snippets on social media and when writing documentation.


Debian-based distros

v="$(curl -s0 -k "${u}" | grep -oP "(?<=/v)[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}(?=/)" | sort -Vu | tail -1)"
wget "${u}/download/v${v}/textimg_${v}_amd64.deb"
sudo dpkg -i ./textimg_${v}_amd64.deb

RHEL-compatible distros

v="$(curl -s0 -k "${u}" | grep -oP "(?<=/v)[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}(?=/)" | sort -Vu | tail -1)"
sudo yum install "${u}/download/v${v}/textimg-${v}-1.el7.x86_64.rpm"


Example 1Example 2Example 3Example 4

Colorize output of top using lolcat and save it as a PNG file:

top -b -n 1 | lolcat | textimg -o /var/tmp/test_${RANDOM}.png

See the output

Save output of screenfetch (see it here) as a graphic file:

screenfetch | textimg -o /var/tmp/test_${RANDOM}.png

See the output

Convert a shell script with syntax highlighting to PNG using the syntax function (you can find it here):

syntax | textimg -o /var/tmp/test_${RANDOM}.png

See the output

Using the fact function (you can find it here), generate fifty PNG images:

for i in `seq 1 50`; do fact | textimg -o /var/tmp/test_${RANDOM}.png; done

See the output

The 'fact' function

#/*       _\|/_
#         (o o)
# +----oOO-{_}-OOo-------------------------------------------------------------+
# |Show a random fact                                                          |
# |                                                                            |
# |Installation:                                                               |
# |-------------                                                               |
# |                                                                            |
# |Install optinal `boxes` and `coreutils` packages:                           |
# |(apt|yum|dnf) install boxes coreutils                                       |
# |                                                                            |
# |Install optional `lolcat` package:                                          |
# |pip install lolcat                                                          |
# +---------------------------------------------------------------------------*/

fact() {
  factx() {
    wget -O - 2>/dev/null | \
    grep \<strong\> | sed "s;^.*<i>\(.*\)</i>.*$;;"
  if hash fmt boxes lolcat 2>/dev/null; then
    factx | fmt -s -w 48 | boxes -d peek -a l -s 79 | lolcat
  elif hash fmt boxes 2>/dev/null; then
    factx | fmt -s -w 48 | boxes -d peek -a l -s 79
  elif hash fmt 2>/dev/null; then
    factx | fmt -s -w 48

Print Friendly, PDF & Email

Leave a Reply