2

When I run command asciiview image.jpg I'm able to view image in the terminal and quit browser using q key. I've tried different ways to redirect the output of the asciiview image.jpg to the console output (stdout) or save in the file such as asciiview image.jpg > ascii_art.txt or asciiview -driver stdout image.jpg > ascii_art.txt but I didn't get a result as I'm expecting. In the first case, I had to manually press Ctrl+C to get a proper image in the text file, in the second case I didn't get anything meaningful that would resemble the picture. Have anyone ideas how I can save image produced by asciiview directly to file or display it in the console output without entering browser and having to press q key?

chicks
  • 1,112
  • 1
  • 9
  • 27

2 Answers2

0

Have you tried echo q | asciiview ?? That seems to be how others have handled embedding asciiview in their process.

echo q | asciiview -driver stdout -kbddriver stdin %s 2>/dev/null

The -kbddriver stdin also looks important here. Throwing errors into /dev/null is also worth considering.

polemon
  • 11,133
  • 11
  • 69
  • 111
chicks
  • 1,112
  • 1
  • 9
  • 27
  • When I set `driver stdout` the result isn't the same quality as ASCII art produced by the same `asciiview %s` command. Example: - image produced by command `asciiview %s`: https://imgur.com/a/IGeeLxi, - image produced by command `echo q | asciiview -driver stdout -kbddriver stdin %s 2>/dev/null`: https://imgur.com/a/aqCQvhs –  May 12 '19 at 18:38
  • Playing with your terminal width might help. Further investigation would require digging into the source code. http://aa-project.sourceforge.net/ has links to the sources and mentions some other packages, like gimp, that supposedly have interoperability with with asciiview. – chicks May 12 '19 at 18:58
  • Does exist any simpler way to achieve it? I tried other programs such as jp2a or img2txt but asciiview gives me the best results. –  May 14 '19 at 19:42
  • Not that I can think of. – chicks May 14 '19 at 20:12
  • @polemon It was quoted because that code came from https://www.emacswiki.org/emacs/ImageMode (which was linked in the answer). – chicks Oct 06 '21 at 23:32
  • 1
    Well, then let's put it in a quotation block then, but I think removing the actual `"` makes it a little clearer... – polemon Oct 06 '21 at 23:43
0

A simple solution is to use the s key... I suppose that's similar to the q key process.

  • go to the output file
  • hit the 's' key on the keyboard.
  • Follow the prompts for type, width etc.
  • Save requires a Y (not just the default way... if you know what I mean) ;)

Works better with pnm - export original image to pnm format for best results.

enter image description here