Skip to main content

Python bindings for Chafa. Visualize images with text in python.

Project description


Terminal graphics with Python!

📙 Docs  -  🌱 Tutorial  -  💾 Examples

PyPI   GitHub Workflow Status   Sneks

What is this?

Have you ever wanted to display an image your TUI Python application? Well, now you can!

Chafa is a wonderful command-line utility, created by Hans Petter Jansson, for visualizing images in the terminal. In Jansson's own words:

The future is (still) now!

The premier UX of the 21st century just got a little better: With chafa, you can now view very, very reasonable approximations of pictures and animations in the comfort of your favorite terminal emulator. The power of ANSI X3.64 compels you! is a python wrapper for the chafa library so you can use rad graphics in your cool Python applications! The library tries to be intuitive and aims to produce very readable code.

Features include:

  • ⚡ Modern and intuitive Python API
  • 📖 Extensive documentation and a tutorial
  • 📟 Generate text based approximations of images in (almost) any terminal emulator
  • 6️⃣ Sixels, 😸 Kitty and 🍎 ITerm2 image protocols support
  • 🐧 Linux, 🍎 MacOS (x86 and ARM), 🪟 Windows support


Here is a picture of a cute snake rendered to text using

✏️ Code

For more examples, head on over to the docs at

from chafa import *
from chafa.loader import Loader

# The font ratio of JetBrains Mono (width/height)
FONT_RATIO = 11/24

# Create a canvas config
config = CanvasConfig()

# Configure the canvas geometry
config.width  = 40
config.height = 40

# Load the snake
image = Loader("./snake.jpg")

# Configure the ideal canvas geometry based on our FONT_RATIO

# Init the canvas
canvas = Canvas(config)

# Draw to the canvs
   image.width, image.height,

# Print the output
output = canvas.print()


Where can I get it? is available on PyPi. You can install it by running

pip install

If you want to use the included Loader class to load images, you will also need to install MagickWand.


📬 P.S. The snakes don't bite (I think...) 🐍🐍🐍🐍🐍

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution (3.2 MB view hashes)

Uploaded source

Built Distributions (1.7 MB view hashes)

Uploaded cp311 (1.7 MB view hashes)

Uploaded cp310 (1.7 MB view hashes)

Uploaded cp39 (1.7 MB view hashes)

Uploaded cp38

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page