haotianblog
Image to ANSI Art
Search
Ask the AI

Image to ANSI Art

Convert an image into coloured character art you can paste straight into a terminal. It uses Unicode quadrant block characters plus 24-bit truecolour escape sequences, so each character cell carries 2×2 pixels — four times the resolution of ordinary ASCII art.

Nothing is uploaded. Decoding, scaling, colour selection and mask matching all happen in your own browser; the server sends one static page and then plays no further part. The preview and download link exist only in the current tab and vanish on reload.

Image to truecolor Unicode quadrant ANSI

Drop an image and the browser will resample it to a terminal grid, then encode each cell with Unicode quadrant blocks and 24-bit ANSI foreground/background colors.

Files are processed locally in this browser and are not uploaded; the generated download link and preview expire after 30 minutes.

Read the implementation notes
Download .ans
Waiting for an image

After downloading, run it in a truecolor-capable terminal: cat filename.ans


        

Why each cell gets only two colours

A terminal cell can hold one foreground and one background colour. Quadrant block characters (U+2596 through U+259F, plus space and full block) encode shape through which quadrants the foreground fills — 16 combinations, 16 masks.

So the core of the conversion is not colour choice but picking, from those 16 masks, the one that minimises total error once the covered pixels take one colour and the rest take another. The tool tries all 16 masks on every 2×2 block, computes the optimal foreground and background for each, and keeps the lowest residual.

That also explains the characteristic failure: if a 2×2 block contains three or more distinctly different colours, no mask can bring the error down, and the output shows a visible banding artefact. Smooth gradients convert best; high-frequency detail and thin lines smear.

Using the output

The output is plain text carrying ANSI escape sequences. cat it to a terminal and it renders — given three preconditions:

  • The terminal must support 24-bit truecolour. iTerm2, Windows Terminal and modern GNOME Terminal do; older xterm builds and some SSH clients cap at 256 colours, which forces nearest-colour mapping and looks markedly worse.
  • The font must contain quadrant block glyphs. Missing glyphs render as boxes or blanks. Most monospaced programming fonts include them; some stripped-down fonts do not.
  • The line width must fit. Output width is fixed; a narrower terminal wraps every line and the whole image shears. Set the output width to the target terminal before converting.

Pasted somewhere that does not interpret escape sequences — most web text boxes, word processors — you will see runs of ESC[38;2;...m. That is not a generation fault; the receiver simply does not parse ANSI.

Tuning

Width is the only parameter that genuinely needs attention, and it sets both resolution and file size. As a rule of thumb: 60-80 characters for a README or chat window, 100-160 for full-screen display. Doubling the width roughly quadruples the byte count — every character carries its own colour escape sequence, which is not cheap.

Related reading

Scroll down