Is there a command-line program (for Linux) that can convert an image to ascii art and then save that output as an image e.g. jpg or png?

To illustrate what I'm in need of, I want to convert the image below into ascii art enter image description here

The output that I desire from a program should be similar to this one, which was created by taking a screenshot of the output of an image-to-ascii converter (the output was pure text)

enter image description here

I'm aware that GIMP has the ability to save an image as ascii art and aview can also convert an image to ascii. However, the former cannot be done via the command line and the latter only lets you view the output, not save it (I don't want to resort to taking a screenshot of the output).

I'm also aware that libcaca can save its output to an image, but it only outputs colourful ascii, like below.

enter image description here

Made by converting the source image to greyscale and then with the following command:

img2txt -W 70 -f tga input.jpg > output.tga

The reason for wanting a command-line program is to batch process a folder full of images.

  • 1
    I have never tried it, but I do know that it is possible to pipe text to convert (ImageMagick). If you set the output -f of img2txt to ansi (rather than colored ansi), you can pipe the result to convert (or other suitable software)
    – horatio
    Commented May 28, 2013 at 15:06
  • @horatio: convert seems to expect a file input and refuses to read from a pipe. We can do it via a temporary file anyway.
    – Takkat
    Commented May 28, 2013 at 18:17
  • Related: askubuntu.com/questions/298200/… Commented Oct 10, 2019 at 9:42

6 Answers 6


In case you seem to be running Linux you may stitch the applications easily together to get the desired result. This can then also be incorporated in your batch processing script.

The example below makes use of jp2a, a powerfull JPG to ASCII-art converter with many options to achieve desired results (consult the manpage). We then further process the resulting ASCII text file to an image using convert from the ImageMagick suite. Again there are many options to fine tune the result. Both applications are likely to be available from your distribution's repositories.

Below sample script will produce an ASCII-art image (format depending on the extension we give, .jpg is for JPEG) from an input JPEG-image. The source is rendered to 160 character width at 6 pt. This will then just fit on the default page size as pre-defined from convert.

#! /bin/bash
#Usage ./j2asc infile.jpg outfile.jpg

echo "converting $1 to $2"
jp2a --width=160 -i  $1 --output=tmp.txt
convert -font Courier -pointsize 6 tmp.txt $2
  • This is probably the closest I'll get to my desired output. Thanks! Commented May 30, 2013 at 10:01
  • Is there a way to specify the width to be something other then 835px? I want to convert the ascii art to a 1920x1080 wallpaper image but when I pass the -resize 1920x1080 option the width remains at 835px.
    – user23509
    Commented May 10, 2014 at 20:34
  • @awashburn: image size is determined by character number (width) and pointsize. Enlarge pointsize for a larger output or scale the resulting image in a second run.
    – Takkat
    Commented May 10, 2014 at 22:47
  • 1
    For MacOS users: jp2a is also available via homebrew and running: brew install jp2a.
    – k0pernikus
    Commented Jul 8, 2014 at 9:27
  • 1
    Also consider a direct output to html in some cases: jp2a --html --width=160 --chars="\'\"love" input.jpg --output=output.htm. You can specify your preferred set of chars for the rendering(you will have to escape metacharacters if you want to use them). For jp2a see also AUR for Arch.
    – user29318
    Commented Nov 23, 2014 at 17:06

You can use this python code I created to create ascii art from still images and videos:


Example output

Original enter image description here

ASCII art output (python ascii_movie_image_ver_1.py cat.jpg 4 10) enter image description here

  • 2
    links come and go, even if it your own site... could you please add two screenshots of "before" and "after" using your code?
    – Ilan
    Commented Apr 15, 2014 at 6:25
  • 4
    @Ilan I've added an example and pointed to a public git repository Commented May 5, 2014 at 20:19
  • The link of gist is 404 and the code and gist from tutorial is not indent correctly(mixed use of tab and space) and error prone(because of duplicated from PIL import Image and import Image. And import ImageOps instead of from PIL import ImageOps). I created gist to fix this.
    – 林果皞
    Commented Dec 17, 2020 at 9:57

You seem to be Using Linux, and already know libcaca. There is another lib that does exactly what you say (Image to Ascii on command line): Aalib.

There are many programs do this. This one works both on Linux and windows. Doesn't use external libraries, full source code available, etc...

  • As far as I'm aware Aalib can't save its output directly to an image - some method involving screenshots would need to be used, which wouldn't be reliable for large images. If there is a way to do it using Aalib could you update your answer? The program you mentioned looks really good. Does it do batch conversion and is there a command-line interface for it? Commented Nov 24, 2014 at 12:14

In Node.js Knockout 2012, there was a winning submission that took a webcam video feed and spit out an "ascii feed":


Asciigram page

Asciigram is a "productivity tool" that allows you to creates ASCII videos and images using your webcam. You can also create ASCII images dragging images onto the page.[Link]

It's not exactly command line, but maybe you can retrofit it for your needs. The library they use to convert the image to ascii is called Jscii.

  • 2
    It only outputs text and not images. Plus, it's not a command line program Commented May 28, 2013 at 20:50

As long as I am aware that program doesn't have a command line interface, but does convert images to text and then to images. Source is available, so you can use it to write your own tool.

You are right, aalib doesn't output images, but it does output text. As well as many other programs that work on command line.

If you're using Linux, there is a command line program called asciitopgm that will convert ascii text to a bitmap. It's part of the netpbm package.

So you can use a combination of tools:

  1. aalib to draw an image using text
  2. asciitopgm to create a pgm bitmap with the text file.
  3. (optional) Use convert (From Imagemagick package) to convert the pgm to any other raster format you want.

I think you can do what you wanted to this way.


I know it's a bit late, but I thought I'd post this anyway in case someone stumbles in here by chance 😅

You can use a CLI tool I recently created, ascii-image-converter. It's available on snap:

sudo snap install ascii-image-converter

Or you can visit the repo if you directly want the binaries or something: https://github.com/TheZoraiz/ascii-image-converter#installation

It currently supports jpeg, png, webp, bmp and tiff image formats so it'll work on most images you encounter.

It covers all of your use-cases and can save ascii art as a png image. This command would print and save the ascii art image in the same directory:

ascii-image-converter myImage.jpeg -s .

There's a bunch more flags for more customization, including providing your own ascii character set for mapping against. You can read the documentation for more details. I'm working on improving it and integrating new features. Give it a try! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.