Chafa image conversion
Chafa is a command-line utility that enables users to print and display images directly within the terminal. It can also convert images into ASCII or colored character art, allowing them to be viewed in a text-based environment.
It can convert various image formats, such as JPEG, PNG, GIF, and BMP, into ASCII or colored character representations. It utilizes special characters and symbols to create an artistic representation of the image within the terminal.
Install
python
1
pip install chafa.py
nodejs
1
npm install chafa-wasm
Filters
ASCII Art
The tool can convert images into ASCII art, which is a technique where characters from the ASCII character set are used to represent different shades and patterns in an image. This allows users to view images using text characters, which can be useful in situations where graphical interfaces are not available or when working with text-based environments.
- ASCII black and white.
basic-ascii.sh 1
chafa -c none --symbols none --fill ascii /path/to/file
Colored Output
It supports various color modes:
ANSI 8-bit.
8-bits.sh 1
chafa -c 8 /path/to/file
ANSI 24-bit true color.
24-bits.sh 1
chafa -c full /path/to/file
grayscale.
24-bits.sh 1
chafa -c nnone /path/to/file
Customization Options
Users can:
specify the width and height of the output.
length-width.sh 1
chafa -w 9 full /path/to/file
adjust the character set used for rendering.
monochome-braille.sh 1
chafa -c none --symbols braille /path/to/file
set the background and foreground colors.
pixelated.sh 1
chafa -w 9 -c none --symbols braille --fg gray60 /path/to/file
apply various dithering and scaling algorithms to enhance the image quality
pixelated.sh 1
chafa --symbols vhalf /path/to/file
apply blapinus Art! fonts.
art-fonts.sh 1
2
3sudo cp blapinus.pcf.gz /usr/share/fonts/misc/
xterm -font -blap-*
chafa -f symbols --glyph-file blapinus.pcf.gz --symbols imported /path/to/file
Terminal Compatibility
It is designed to work with a wide range of terminal emulators.
- Basic rendering command.
1
chafa /path/to/file
Performance Optimization
It is optimized for performance to ensure efficient image rendering, even for large and complex images. It leverages multi-threading and parallel processing techniques to speed up the conversion process and provide real-time or near-real-time image display within the terminal.
Improve image rendering with small color palettes using dithering:
dithering.sh: 1
chafa -c 16 --dither ordered /path/to/file
Teletext filter
teletext.sh 1
chafa -c 8 --symbols legacy+space /path/to/file
Integration and Automation
- It can be easily integrated into scripts and automated workflows.
- It provides command-line options and supports standard input/output, allowing users to pipe image data and automate image conversion tasks.