Python bindings for Chafa. Visualize images with text in python.
Project description
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!
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
- MagickWand
- Python 3.8 or later
📬 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.1.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6baaac82d9853c6e450d9ae0a4d5deca5459d1af1edd8f5f9ebf3d1831f2e79b |
|
MD5 | af119836e7eabad97632ae7b95daa87b |
|
BLAKE2b-256 | 28a12deca81c73d9ee1e4a1988797ec671c3d2abf33a89c92f0b87913ed21910 |
Hashes for chafa.py-1.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ac75f5b850bf4124f8a6854fdae0fc96a6807e3ede4d4c273cd1faab4a40d4d |
|
MD5 | 53269e64f8fc38e9dfe613369197afd2 |
|
BLAKE2b-256 | a0b42b6468445923d9024e20336e7758708a1810d134cff10474424ee2043c43 |
Hashes for chafa.py-1.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 364c6688bf3b5472d2b8142ad69ea5e54c8194bd18b4daea700b11a0a5623f2d |
|
MD5 | 173ce9bf543fdd0448d981ab006eec77 |
|
BLAKE2b-256 | 230a045e199c4e436e38eee0e4d99a6b43067122dadad7a4362eb261c966278b |
Hashes for chafa.py-1.1.1-cp311-cp311-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a1adfd60c8b092bb2cc90ce5a25d8616fad587388e6e3ad98c70e8c0273160e |
|
MD5 | e58b5be1ef56a6b17cd3b15c3a44f588 |
|
BLAKE2b-256 | bc24dee6a74cea5969dee7154276020d385ddb2ec3314b04d068b892f2b0249e |
Hashes for chafa.py-1.1.1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a01a96e902571e5878e25f0b854cf5c368dbedbca94926ea6c797e6efde75586 |
|
MD5 | b7fecf91ce677519ccbcb4567cd6f0af |
|
BLAKE2b-256 | 421be8ae226376cf011996f28e2cd700b931056f0fc06a316a3e9633d5a3dc5f |
Hashes for chafa.py-1.1.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cd0a6cc16d22589868ada0cccd258d4f547579a3500583f663cc36bd490e1c3 |
|
MD5 | 614b5ea91f21a219ae5bc2a98c2426d7 |
|
BLAKE2b-256 | 643db57f6f65157530d878f9d39b5a5ed435b48e388f56f62606c05a7334faab |
Hashes for chafa.py-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3ddad23cce50c7ae8a97974fa3b014fd2424879d28ef98a07666232f2b0ce74 |
|
MD5 | 2ea66e0154515771d1f9e44f4ef3efe6 |
|
BLAKE2b-256 | 8a5932aae92cf305ea397cd7d9b338802c8037cdcd403aa445d8c71f774f75d5 |
Hashes for chafa.py-1.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 313182fdd54534e40af5b47beb43b5e8c569fd72d9e9f4ddea8e4d5180009f8b |
|
MD5 | 179570841d1ce6d5374e6d7b6f91b8ba |
|
BLAKE2b-256 | a539353b6e553d8a640d07b87687748dd39906613bb88d7c2d4fb788c94c12eb |
Hashes for chafa.py-1.1.1-cp310-cp310-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d36243eeea4832f501f5bb93cb353fc00b56a3132fa9c7797273c4efb7df2d0b |
|
MD5 | 1ea1350a0279cdc9fc231ff6356be448 |
|
BLAKE2b-256 | 5e4b7d1ec25a5454056d58ce477cfedd429152d744c3bf8d120e97c85bbd4711 |
Hashes for chafa.py-1.1.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca6d2450dc667f459e7dfd7d31b726867a1f59fe3b5c7c350618ce420f31db36 |
|
MD5 | c8bcecce9ac413e7eb23d523a80b7185 |
|
BLAKE2b-256 | 8eb8703ac186737898acc8cfd6a2798f572e94ece37793e239bd3e1d2a5cecc5 |
Hashes for chafa.py-1.1.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb3ca2fa514d2aa41e88ac256cc540f8ab53743678df3733a780c82d250feb44 |
|
MD5 | 0de37a2a48b4367774db2e56cef5c037 |
|
BLAKE2b-256 | d0e32699f846dbac739583ace96a17620cc893603ce4fb4fea06dad32e807bcd |
Hashes for chafa.py-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b01f6d2fbae7af55e27eb73131398fe6651f0cd1b65a507f6cd4fec90bd68564 |
|
MD5 | b3b11b9eb3ef73d5f4581f2f2b24b56f |
|
BLAKE2b-256 | d5d35747d6ccaeb2275ea6c41d36dc7882328b86e03a4353c1db6fe2f5ceff29 |
Hashes for chafa.py-1.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a661a4737737407eae04479a20b2b32c3774aa6f41f482cacd8679058d504759 |
|
MD5 | 40ce63699f103137dcb651eb658d2120 |
|
BLAKE2b-256 | e4b676a975e4585efc512371d55d2678ed4436242d709c1114973cbaadb53fa2 |
Hashes for chafa.py-1.1.1-cp39-cp39-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82c25adc4a9e86737a5197a6878ca3564ced90db9e05f7e2ff478ac6d12b1baa |
|
MD5 | f6e94981a94044b52ef6f47e35885531 |
|
BLAKE2b-256 | 17d58ef508d07b8f7535291b29e54b011540b7f5aeab7f69cbfd22e339d94e94 |
Hashes for chafa.py-1.1.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 869826ce69e1d3f748741a1383a92867b841abed5b541c6e7d6d942a6962a873 |
|
MD5 | 60d4a0e9f5d9d6dd976afc45cf70cb0b |
|
BLAKE2b-256 | b6c7c055696c450194a291b1f9e98311d50b117cb26a713d054ea6c2d33731cf |
Hashes for chafa.py-1.1.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc06787d790962e0c174270fc9f9444a6638fc223d98943557c9a8c017a0a1f4 |
|
MD5 | b06b8d38ca9835e7c008dafc918b4bb5 |
|
BLAKE2b-256 | 0e4ccd19d0ea61565f839f21a7cfa224a8f312f7a8289efabb208a6fb9c144c2 |
Hashes for chafa.py-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d1cd88c831903827f0082ec3afe7328ac8bdf2040d28c3ef9d722754fa27a6e |
|
MD5 | 1a3218fbf9fd7fde0f00d01913fc569d |
|
BLAKE2b-256 | dfab36c066d0b306bfd2f78d2a15dbcf25c9e77e1576ce4ca0cc4d5d65893d20 |
Hashes for chafa.py-1.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e712f00da1c41093680d73b5ac8618ceefa421e1971be1cf06efc22ae1bf34fb |
|
MD5 | 48a425bcaefac3fd0d66cc80aaf8475f |
|
BLAKE2b-256 | a7057ed49146b7b0443f8db354b242ba817d6f8d0e2bd64197eab83c8887d962 |
Hashes for chafa.py-1.1.1-cp38-cp38-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00a624cf5fa4523bd4bef0d5b2a384866927da96e0121ae6e7d521c0bd8184ed |
|
MD5 | df72f15d235dc69b63309af974279ecb |
|
BLAKE2b-256 | 8d39134077e6aade63a2d9695c1f4d00e39aa442c51222e58c724b54d1b4271e |
Hashes for chafa.py-1.1.1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0403c0f665a4db68cebc11ee32f4e3f17fdaee27fb2a790144fc715c237f4459 |
|
MD5 | 5a879f7f6953b0ac0db2d78cfe0bd556 |
|
BLAKE2b-256 | cfa3714e87653d6016197a2999ba7a4a387cb97802788fdf8f6f1a5716d2bbaa |