img2xterm: Dot by dot, block by block

For img2xterm, the idea is to translate from conventional images to block characters visible in a terminal emulator. I say that up front because if you try this in a virtual console, I’m fairly certain you won’t get quite the same results.

2014-09-01-6m47421-img2xterm

To be fair, usually when I say, “You can’t do this in a virtual console,” I go straightaway and try it, to make sure I’m not being stupid. This time it honestly did work, but the results were rather … alarming. The image was there, but Smiley looked a little sinister. 😯

Be that as it may, what’s happening is a translation from pixel to block character, staying faithful to the color, shade and even a certain degree of visual accuracy. It’s rather impressive, when you think about it: img2xterm take make a picture on your screen pixel by pixel, and convert it into block character sequences that your terminal understands.

A couple of caveats though: Note that I said “pixel by pixel.” That means exactly that: It’s a one-to-one representation of the image you feed it. img2xterm — as far as I can tell — doesn’t resize images to fit your terminal, it only translates between the two “modes.” That means if you feed it a 1600×1200 image, it will faithfully trudge through 1,920,000 pixels, dumping its best efforts to your terminal, scrolling and scrolling and scrolling until it finishes the entire field.

So … you’ll probably want to resize your image first. 😉 What you see above was shrunk for a 114×46 terminal, and probably could have been shaved down a little more.

Second, the output is terminal escape sequences, which you can see if you dump img2xterm to a file and open it in a text editor, or if you use the img2cow utility. So while things like caca or aalib are converting to text and shade or color, img2xterm is using block characters to “render” the results. It can look a little different.

All that aside, this is a nifty tool for making custom logins, converting small-scale icons or images into text-based artwork, or … or you decide. I am sure you can think of one or two things to do with this. 😀

3 thoughts on “img2xterm: Dot by dot, block by block

  1. Pingback: imgcurses: Best of most worlds | Inconsolation

  2. Pingback: Links 2/9/2014: GNU/Linux in BBC, Calls Against systemd | Techrights

  3. Pingback: imgcurses: Best of most worlds | Linux Admins

Comments are closed.