← All projects
vlangcli

image-term

A terminal image viewer written in V that renders images as colourful ASCII mosaics. It scales the image to fit your terminal, corrects for the aspect ratio of terminal characters and averages the colours within each block of pixels.

Licence

A terminal image viewer written in V that renders images as colourful ASCII mosaics. It’s based on the blog post Convert an Image into Colourful Ascii Art, and I wrote about building it in Convert an Image into Colourful Ascii Art - Vlang Edition.

An image drawn in coloured characters in the terminal

How it works

image-term loads an image, resizes it to fit your terminal and draws it with coloured @ characters. It:

  • Detects the size of your terminal and scales the image to fit
  • Corrects for the aspect ratio of terminal characters, which are taller than they are wide
  • Averages the colours of the pixels within each block, so each character has the right colour
  • Supports greyscale, RGB and RGBA images through stb_image

Requirements

  • The V compiler
  • A terminal with true colour (24-bit) support

Building

v -o image-term .

Usage

./image-term <image-path>

For example:

./image-term ~/Pictures/holiday.jpg

It reads any format stb_image supports: JPEG, PNG, BMP, GIF, PSD, TGA, HDR, PIC and PNM.

Licence

Apache 2.0. See LICENSE.