Search

Creating ASCII Art

Creating ASCII Art

So you want some killer ASCII art for your scripts so people will know how leet you are. Maybe this will help (leetness not guaranteed).

  1. The first thing you need to do is find an image to work with. For this example I’m going to use this one.
image
  1. Now you are going to need the software to do it for you. I used ascii-image-convertor, I tried a few and this one got the best results for me. Run the below commands to have it installed. Find more information about the package here. Embed GitHubEmbed GitHub
    1. Add to sources (when prompted enter the sudo password).
    2. echo 'deb [trusted=yes] https://apt.fury.io/ascii-image-converter/ /' \
      | sudo tee /etc/apt/sources.list.d/ascii-image-converter.list
      image

      b. Update the local package index

      sudo apt update
      image

      c. Install the ascii-image-converter package.

      sudo apt install -y ascii-image-converter
      image
  2. Now the art can be generated. Be sure to check the help file or the project source code linked above on git to get further information on the appropriate switches to use to get the image exactly how you like.
ascii-image-converter -C --color-bg -W 100 hulk.png
image
  1. Once you have tweaked the parameters to get the image looking exactly as you like. It’s time to output it into a file.
ascii-image-converter -C --color-bg -W 100 hulk.png > hulk.sh
image
  1. We now need to make a minor modification so that it will display correctly in a bash script. Run the below command to clean up the output.
sed -i "s/^/printf '%s\\\\n' \"/; s/\$/\"/" "hulk.sh"
image
  1. Before the we run the file it needs to be made executable.
chmod +x hulk.sh
image
  1. Now we have a bash script that when run will display some super leet ASCII and will totally make up for any shitty coding that you add to the rest of your script.
image