Python bindings for Chafa. Visualize images with text in python.
Project description
What is this?
Have you ever wanted to display an image in 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!
chafa.py is a python wrapper for the chafa library so you can use rad graphics in your cool Python applications! The chafa.py 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
Example
Here is a picture of a cute snake rendered to text using chafa.py:
✏️ Code
For more examples, head on over to the docs at chafapy.mage.black.
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
config.calc_canvas_geometry(
image.width,
image.height,
FONT_RATIO
)
# Init the canvas
canvas = Canvas(config)
# Draw to the canvs
canvas.draw_all_pixels(
image.pixel_type,
image.get_pixels(),
image.width, image.height,
image.rowstride
)
# Print the output
output = canvas.print()
print(output.decode())
Where can I get it?
Chafa.py is available on PyPI. You can install it by running
pip install chafa.py
If you want to use the included Loader class to load images, you will also need to install MagickWand.
Dependencies
- Python 3.8 or later
Optional Dependencies
- MagickWand (for the Loader class)
📬 P.S. The snakes don't bite (I think...)
🐍🐍🐍🐍🐍Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for chafa.py-1.2.0-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 058690ce9c229fe225bd371ccf46cbb356d034b6cd242b8ef15bfc65a0a4ae70 |
|
MD5 | 8c178aaf263054b7ed82f7c62de885c3 |
|
BLAKE2b-256 | fc6519c96629964fe9761a8df2ef8f5038a7e8b0dc6b74c9c455accea84e4a38 |
Hashes for chafa.py-1.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d60edaef3db3baa43200d351311fece0788d935862af11e002b95f16e87be06 |
|
MD5 | 4f595a27fee0997f8436f58835777742 |
|
BLAKE2b-256 | 719a52b1d90329a0d7fcb6c2132b2de4576c54fb1aebe044089b3685cc7c6052 |
Hashes for chafa.py-1.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3fa0c59fc8ab2c6c50358c66f6414ada354d1f693507a7c89e9405029cfca8c |
|
MD5 | 7eea5d69538393ae8d34afdb0fe22a1b |
|
BLAKE2b-256 | 185ac7c152dd9dfd1de403233acdab5800f1d33f7032bd8fb4f4c92433561aa0 |
Hashes for chafa.py-1.2.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 504056d5fdbc619339d200c8eb7d708aa748f8f0fcfba30482cbae28bd1cf1cd |
|
MD5 | 831d78d999b64913605113d0880ef875 |
|
BLAKE2b-256 | 2893a75259258678a96567b73cfc544ebeadbe0a397d02f62cd21a829a4d938a |
Hashes for chafa.py-1.2.0-cp313-cp313-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fe33f94ae13e854650475859a49d9e332519cc0629227641639096674bd2e2e |
|
MD5 | 272b7cf6ec9d22b73327bdffc5ab6a65 |
|
BLAKE2b-256 | 1a5a76fdb02e4142333c61166538ba75662735a3d3c13cc3e161e54e47b33d4a |
Hashes for chafa.py-1.2.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d2bad8d024f484d09358ece4c4787c11bc4ce54dc1839ffc91259a18e824800 |
|
MD5 | 5f4a34d4b85339c2e28afef19554a296 |
|
BLAKE2b-256 | a782cb88ad48949a8704092aac50e3acdbf14d13a0ca059dfb853529960e8138 |
Hashes for chafa.py-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 626c8f64311ac595dc10d530dd777371658e2698da96b198598582c79db73985 |
|
MD5 | 23f8f9aec5b7635f90182cb65ca167d0 |
|
BLAKE2b-256 | f5dc042953d51a08703cf7934cd2e27e0aa3ececbf3bd2abe31558e3cb94d621 |
Hashes for chafa.py-1.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 672695165adb66f73b33da1933585aa945a7ae22c410c9769a9f7efe515db7af |
|
MD5 | 87bd7b95cf24f7dfd3d6aa9ce6684574 |
|
BLAKE2b-256 | 20e6fe780467111a87842e7fb9d509c4206ed79da5742f4537c9faba7369c808 |
Hashes for chafa.py-1.2.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98991b143fba6c22a7fa93bf6a2bcef8c22b4949796de1e15293e31f437228ee |
|
MD5 | 4a99fb724cca5e55c4a35095d2f99c92 |
|
BLAKE2b-256 | 1cd18f75394b42a08920084daf099775cf73f193a16acafddd6b08c55d6d9813 |
Hashes for chafa.py-1.2.0-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32069be6c7fc0f472dfd1e948be171e373b07d7b32db38ca4da1c187fcd4fd4b |
|
MD5 | 80b7e7c980d6b2f40c8300d62e68a9ba |
|
BLAKE2b-256 | a14f83d0432d05e20a0063aa8106b578c345269bd35b5d9d2610fcebcb01f16b |
Hashes for chafa.py-1.2.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdcb6da9a14db2889dc9f71e98fe19c54e1f7806bc4be84b00b2b541c3fabb5d |
|
MD5 | aad0190be11c9b1e6c766eaf2ae82e3d |
|
BLAKE2b-256 | 1280d84e4bcfc214271ff8bff557ddcccac49b2f551a9dd928f712e09af431a8 |
Hashes for chafa.py-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de0e482e69a40cf9d0fcb7c42223d6d235cfa0d16efcde03dc01381056216333 |
|
MD5 | 785673b2e470004d2d0bbd2e1dc83724 |
|
BLAKE2b-256 | 46d5ff3d5df016a6dde89476718ef9c9ab1f82ceb4d20f689635fba9dbde8e7d |
Hashes for chafa.py-1.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff03e9a774712b20ce689fb2505993f77e90a076e10dcc1e15f4837a0bf6467c |
|
MD5 | a1204d57cfac96c5597ea64b5606bdc6 |
|
BLAKE2b-256 | 5d76469507a7caa688a4d814def96061ce1ab4b1643872d2886b5d5cc87d7ca3 |
Hashes for chafa.py-1.2.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a64af6bb705d29404d5d8baa0892ba55ccdc025b62636a67e56b8e475e676b9 |
|
MD5 | 2acb8221aef44fbe8f2362b8a1daa456 |
|
BLAKE2b-256 | 1d91a5ace870ded23e28c0930efb9e315bc3740ed477d3795ca947b91ddde976 |
Hashes for chafa.py-1.2.0-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d25d50cdc5e1e854a3b3cfcb8f7011caddc8eac479cafa1b017f50ec9e2d3225 |
|
MD5 | b70a6525f709e15b1c28944762c5e83f |
|
BLAKE2b-256 | 082ee43250031cab23def3c4a5ba6904bbb86c27639deab447cbabe82e8e1e56 |
Hashes for chafa.py-1.2.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94ab201a88873cd1145d37ee4a7317109dee59b611770a51b5dcddc67b4715b3 |
|
MD5 | 0e8ba5ac9afa893d92aa7483eea080e9 |
|
BLAKE2b-256 | 42997699cf00a3b67b8c339bc22fd312a42d9f01fa686d9f818953414d37bfbd |
Hashes for chafa.py-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b260cb2b4f5a59a7a0d7354bb68a26389f238d3ea18d4ebe46d5553bfc149da3 |
|
MD5 | be25d4e32785f02901bbf4e6d26ed700 |
|
BLAKE2b-256 | ab230e7e9cf978839e57f7484c0c737416497316bb92f758a5ca70abfd09bc6b |
Hashes for chafa.py-1.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bb55fad333d3fab2847ba907bb88c2e0413eb97c75cafd1cbb1a2a5925c3dc4 |
|
MD5 | 35401cd476447a3f4f8efffb2639026c |
|
BLAKE2b-256 | 6128a88d978808966f2676e08effddd85cc4ce1e6aed07f9eaaeb4af9ab19583 |
Hashes for chafa.py-1.2.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 078ce3c66b91dc6d700166e456153804eaf8817fe89a873aef8a6754e3ee3619 |
|
MD5 | a8f3300aaba92e6bef2379705990e07b |
|
BLAKE2b-256 | 0b789f1e32e362619e6e93857a4967351fc12e4cdcd0502d880dbde12b628f22 |
Hashes for chafa.py-1.2.0-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03fc9aee392d556981add2301b20ef8fde264772e043fe4608488d0543d45872 |
|
MD5 | d259045977462d301915ef6ea0dc4719 |
|
BLAKE2b-256 | c8b93889b658d1323a9304dfa9c7d3e00b8df5e05bfea07aa891cbd6c6e2c71a |
Hashes for chafa.py-1.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 884fc38dfc54c1622b009546ac1752bd9ae6edc94a8c61530ca4d1517663ad30 |
|
MD5 | ba3ef80d1953c39d92bed761e46a849a |
|
BLAKE2b-256 | 67e04d62c7965a102aa7a0be2d3be43f316a62ba591ee01b4729a13de8199722 |
Hashes for chafa.py-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29e422f4c74917f4afbb2962c28865adb97fb574d71f90b65b9bc8f1c469ac61 |
|
MD5 | 93ef28993b7c425ce354b259a8625929 |
|
BLAKE2b-256 | ed906ac936b2b0116824dc876c530a123f8ddf64bf12adddd178c89a18804e77 |
Hashes for chafa.py-1.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60c9987a40e9186df33ffe3b33ca64437742f26b331f343aa937a6359c9c66f8 |
|
MD5 | e352a432b54864758ce94d7e8a535863 |
|
BLAKE2b-256 | 28f85e039be6a096ba8149558fcdfc425deb2820b1cf5974519c27e6fed29d35 |
Hashes for chafa.py-1.2.0-cp39-cp39-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f975b0fa4c6014b2f71d3d58790fc02ba4299f7918ab03792c46ca69d976e0d2 |
|
MD5 | 917fa8b7381fcba6055d907b532b2c16 |
|
BLAKE2b-256 | f9a5c03e8e7b554a214bf9a2276274b076b89d231a8deaa516bc92d0be49625b |
Hashes for chafa.py-1.2.0-cp39-cp39-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc5cc5168c3d2d389e321fbce58aeb3b70b10563c94c9cd41269b9c5b13579ec |
|
MD5 | dd499b2c37696ea6de39707f7d06d270 |
|
BLAKE2b-256 | 04b633fe3bc45243742af4ad6730e2a21b0c71a2912edf5edb937e0f079977d0 |
Hashes for chafa.py-1.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5425ddf796827e6727e842ddfd89a86ea902b5698e230e786f95199db3c145b |
|
MD5 | fb84d5f007eda790d4820c6ef07f5828 |
|
BLAKE2b-256 | d3399dc41fe6dc62b9f0978b3fe399b2170b0e10f0aa15618a1d77d50659f611 |
Hashes for chafa.py-1.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93017864b9af1ea7aa15de3e28a8f8029da69a27b2f80f8ea42014c04ba9bd96 |
|
MD5 | e5af3331c0b21f4d5bb9f049e867391d |
|
BLAKE2b-256 | 7d784c9a18a563710dfb6333929312c4ec2cc138632500a1d503218fe88e70d5 |
Hashes for chafa.py-1.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b342e20e8d016dd0b28ef7c8e374156d16d7851125487fbfa916af0fa394773f |
|
MD5 | ab545335e93119856bba3c81dd042557 |
|
BLAKE2b-256 | 8b2c2781bd01e2c27c293cafc3cc23be5f1e726b172300319fb97622f4ddee33 |
Hashes for chafa.py-1.2.0-cp38-cp38-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9c286a17a5b8edcbb7004f017fc808bd3f714a25a0e82cf9ed80df18c9d7c24 |
|
MD5 | 2c78d6cf3dc13a0ff0ca31870eb3505a |
|
BLAKE2b-256 | db44e972ab8de6ae5706b0aff314633075ccd0ace93462536b87fd3451320781 |