-   Linux - General (
-   -   View image from command line? (

Rotwang 03-22-2004 02:11 AM

View image from command line?
This may sound strange,

I'm wondering if there's a line command/utility type thing that will let me view an image on the command line. Obviously, I don't mean perfectly rendered- but like ASCII art or something. This actually would be very handy for webservers, when you just want to see which image is which and you can't tell from the filename. From the ascii you could tell if it's a title or a photograph, without having to (start the webserver and) lookup each one in the browser.

phek 03-22-2004 02:51 AM

there are tools which will convert images to other formats such as jpg to png to ascii, a script i have on my slackware machine to do that is:

/usr/bin/djpeg <file> | /usr/bin/ppmtopgm | /usr/bin/pgmtopbm | /usr/bin/pbmtoascii -2x4

or for gifs:

giftopnm LinuxQuestions.gif | pnmtojpeg | djpeg | ppmtopgm | pgmtopbm | pbmtoascii -2x4

you can substitute -2x4 with -1x2 for different sizes. But even still, this will output to a much larger scale than a normal 80 character width of the standard console. Converting the small logo at the top of the page converts to take up the entire width of my 1600x1200 screen at the smaller -2x4 size and both of my dual monitor 3200x1200 resolution at -1x2. Of course these are from the tools installed from a full slackware 8.0 install, it will most likely be different for your distribution, but this will hopefully give you a good idea of what to do. You if its a jpeg just type like jpg<tab><tab> to find something it could convert to and keep doing this until you can convert it to the desired format.

This resolution to the problem is something I came up with like 2 years ago and I've heard of lots of other ways to convert images to ascii since then, but this is the only way I remember of doing it purely from the command line.

All times are GMT -5. The time now is 02:01 PM.