Console image viewer: pbmtoascii

Here’s a neat one-liner I just came up with for those times that you’re stuck at the unix/linux console and really need to peek at an image file but cannot use X11.

This method depicts the image in monochrome ascii art, so is pretty useless for images with any amount of detail or subtlety in them.

It uses imagemagick to convert the input image to an array of monochrome pbm files, using a range of brightness values from 50% up to 150%. It then uses asciitopbm to depict the image using ascii characters. When you execute the command, you will first see a very dark image, which will gradually become very bright. Hopefully at some point in between these two extremes, the shape of whatever is in the image will become apparent.

for i in `seq 50 5 150` ; do convert banana.jpg -thumbnail 80 -modulate $i pbm:- | pbmtoascii - ; done

If you’d like to try this out now, first download the sample banana:

wget http://id.chaosnet.org/junk/banana.jpg

Banana source © Jason Gulledge creative commons

No comments

Post a comment


Name:  
Remember personal info?

Email:
URL:
Comment: Emoticons / Textile

This is not a trick question, but a mechanism for spam prevention.
 

  ( Register your username / Log in )

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Powered by Pivot. RSS Feed & ATOM Feed