Skip to main content

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

Project description

 

chafa.py

 

The snakes don't bite! (I think...)

Docs | Tutorial | Examples

What is this?

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 (undoubtedly pretty cool) Python applications!

chafa.py tries to be very pythonian (I think that's a word) in the sense that most getter and setter functions are simply made to be attributes of Python objects.

Example

Here is a picture of a cute snake rendered to text using chafa.py:

And here is the code that printed this image. 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())

How do I get it?

First, you will need to install chafa. This should be fairly straight forward since chafa packages are available for most linux distributions.

If you want to use the included Loader class to load images for using with chafa.py, you will also need the MagickWand C-library.

From PyPi

Chafa.py is available on PyPi. You can install it by running

pip install chafa.py

From source

There are instructions on building chafa.py from source on Windows or Linux in the docs

Dependencies

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

chafa.py-1.0.2.tar.gz (3.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chafa.py-1.0.2-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

chafa.py-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

chafa.py-1.0.2-cp311-cp311-macosx_12_0_arm64.whl (683.5 kB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

chafa.py-1.0.2-cp311-cp311-macosx_11_0_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

chafa.py-1.0.2-cp311-cp311-macosx_10_16_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.11macOS 10.16+ x86-64

chafa.py-1.0.2-cp311-cp311-macosx_10_16_arm64.whl (683.5 kB view details)

Uploaded CPython 3.11macOS 10.16+ ARM64

chafa.py-1.0.2-cp310-cp310-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.10Windows x86-64

chafa.py-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

chafa.py-1.0.2-cp310-cp310-macosx_12_0_arm64.whl (683.5 kB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

chafa.py-1.0.2-cp310-cp310-macosx_11_0_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

chafa.py-1.0.2-cp310-cp310-macosx_10_16_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.10macOS 10.16+ x86-64

chafa.py-1.0.2-cp310-cp310-macosx_10_16_arm64.whl (683.5 kB view details)

Uploaded CPython 3.10macOS 10.16+ ARM64

chafa.py-1.0.2-cp39-cp39-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.9Windows x86-64

chafa.py-1.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

chafa.py-1.0.2-cp39-cp39-macosx_12_0_arm64.whl (683.5 kB view details)

Uploaded CPython 3.9macOS 12.0+ ARM64

chafa.py-1.0.2-cp39-cp39-macosx_11_0_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

chafa.py-1.0.2-cp39-cp39-macosx_10_16_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.9macOS 10.16+ x86-64

chafa.py-1.0.2-cp39-cp39-macosx_10_16_arm64.whl (683.5 kB view details)

Uploaded CPython 3.9macOS 10.16+ ARM64

chafa.py-1.0.2-cp38-cp38-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.8Windows x86-64

chafa.py-1.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

chafa.py-1.0.2-cp38-cp38-macosx_12_0_arm64.whl (683.5 kB view details)

Uploaded CPython 3.8macOS 12.0+ ARM64

chafa.py-1.0.2-cp38-cp38-macosx_11_0_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

chafa.py-1.0.2-cp38-cp38-macosx_10_16_x86_64.whl (870.6 kB view details)

Uploaded CPython 3.8macOS 10.16+ x86-64

chafa.py-1.0.2-cp38-cp38-macosx_10_16_arm64.whl (683.5 kB view details)

Uploaded CPython 3.8macOS 10.16+ ARM64

File details

Details for the file chafa.py-1.0.2.tar.gz.

File metadata

  • Download URL: chafa.py-1.0.2.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for chafa.py-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6dd24bf22d76bba2c0aae3f4947ef993c16e81db28f7af3331f723157bc9a72b
MD5 7c94ba416a36674da060538324abd589
BLAKE2b-256 67cf0a2743ec544cc356fe9b8f87497b8c1c6fcdcb232ad31b5654827ac04d53

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: chafa.py-1.0.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for chafa.py-1.0.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4ae9ececa393e575f23218832711a40d18be8a418a081037f0641df18654e10e
MD5 b7d56bed0bab89c421da1a87d8bb6f5f
BLAKE2b-256 88e3feafb70cbb0ad8078e66a5577edd0141ef497833d77555505cb1d99aa50f

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e61c4cb95b053012f6da6c984ec67ec6a5daa6a106a51ea5d63bb8b9404a343e
MD5 81882fd044d2f11a5abe7372a9e53a92
BLAKE2b-256 3546b28259c2f7eaf3df07a63057eb9745ae7b8e28f2ea4bee738e464b262ad8

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp311-cp311-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 83acb23cdbbf8041fa6134076050fee6e3cd49927a0fa106ba3459cf0bd47f97
MD5 1ab7f042d21ed7f071bec51be1d70aa4
BLAKE2b-256 eccde07aacbf59b4e5ca2b49ac67fed18738ad83e54fe06f6f9e876ca0632250

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 359a9ebc09b3c2b6d2a21bcdd1c63e60c02b545a27095369b3ce5b05fc2b8d6a
MD5 e4b2a59bf16e331636eb89012946f5db
BLAKE2b-256 9d30b590b625f648d83b86048cfe80e5757df5288992cca1adcdaeeaa508ba99

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp311-cp311-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp311-cp311-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 2d840d85ce1a03108af21141ae886e452f0c2f7df9723b83740b8fe4d729582c
MD5 91daa36e2272d0652a36b717ef78c5fd
BLAKE2b-256 2e3e424d9c19ccf1cc823b699b093cbefd84c0471ee981a8ff11b46e99b71e52

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp311-cp311-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp311-cp311-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 90cd299d02c44e6fc7a0db6e0b5955763768f6eeef709129cb972a88d8176f61
MD5 d99f965aba8afed46b86cab1254d1cb9
BLAKE2b-256 609361667feb08e3165791dd543d8825acfb6b8dc07c4ebd0dd5193769919f78

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: chafa.py-1.0.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for chafa.py-1.0.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 843b8cae97408ad8308e11a1ddcd148ba0364c79f9f7755e2ae10094d3fddf2a
MD5 17599ea9cede25f20c5c9961a4ad7923
BLAKE2b-256 08e5313e68958a44cc265d85f1d921a4925d4b4398b84419714da7dc3269af7b

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 815cf25434656306389837a03174283dca7ce9624349c3abebe302e97e5d076e
MD5 e6c77d4b282a2beaead4bd29ee09d354
BLAKE2b-256 af85644550bdf5c68fdc7e4295ecaa3d9c0385a3796720c33015f3838205b80b

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 e8d94b20449b1572d6301bcbd84c031297f775ae65e34afd198f8516a191d89c
MD5 8ddff2ca8343fa9bd7f90e20052dcd1f
BLAKE2b-256 993b46a9d19212f9bf510a3eeb8f2421bc10164ca051a66fd6422cb1e16f36f3

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a2fd01bcc568b32514154add20da7ba5e649eba1172efef4a8d3fa98a23fbbfb
MD5 5a5a9e58fe9473f333a6f9cf0cb81263
BLAKE2b-256 a8bb6608efbf6e4ec6a76c0457330da6f858dd6fece1cc1c5b32a9f12e408542

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp310-cp310-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp310-cp310-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 6763275affd1710ed407b928f97a76f15778276e12b95abb0fc8f0c79550acd4
MD5 909aa8ae6a18d8f57c25b9d462d27e58
BLAKE2b-256 257ee1eea762942d08ddbb2b19ccd5d347ea16c91db7188c4e55fd000071592c

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp310-cp310-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp310-cp310-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 0212f3723d24b69c5a245b862772db6269a52defbe4f182c283b961232a193a8
MD5 feb847d46e8025089ec49c584a7bc3dd
BLAKE2b-256 51a06a8532f07eddd3304048bf68e0b6e4894bb12a098fe394062dd9dd7bc79a

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: chafa.py-1.0.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for chafa.py-1.0.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 29c2af0dcdc819215114a907128a7d8eede2efc1501b928cafd5111f5d70db1e
MD5 2341be565e88133d2788a895d9965a4d
BLAKE2b-256 10f803844c39794066142a0ea38410911425cccaa7e72f28fc7ae6320c1cdce0

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68acc25e54e0c14609234a3e3163555d935a4927b01ea1f7ecebffb344f00713
MD5 a43e6ebe38c2bfd0040bec2294c28c19
BLAKE2b-256 6b0f37f8b6a09d934fefe8f0b3b4f9a7492333bc22fc4a3917f858ad1bb8e26d

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp39-cp39-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 dac9f398db13e4b0b84adb172352daf47b80a45f5c3998b4ae729f002d8ca3af
MD5 8570da9525e0ccd72f81ff7b1f4a0115
BLAKE2b-256 6e6d5d83421887a975c70734840457c0668eb1718c6a06e1e478e7f33cc09dc3

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 e98da71239cbb87faaf0f44aab799df9a8a1bac5a8908b173fdae1183bbdf114
MD5 d0ead3238646e545e9fd177dc34d2d4f
BLAKE2b-256 0f8d257444a7f9dbf955cde1271fcb20bc63298bfa37a4793435ca7df537d44a

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp39-cp39-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp39-cp39-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 85a8c51c5df22f8a3b478eda90d194e5f228a0e4dba4fd1567e235f0a11bc915
MD5 3b156286dcb12dd9f23c3ac3e77dc6b4
BLAKE2b-256 0fe544eec7ee832fedf02419827af6f377df4f0d618e4bf55888e15cfe9bdd29

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp39-cp39-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp39-cp39-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 b58fffc3acb17840c728cf6f71e56e421f9ecc5903e2c3f0c7e8fa72ac33113b
MD5 3824aa1760e3d713f830ff0c42076108
BLAKE2b-256 f689c32ebc43585134caabc4126c011fb1c5eec357d31fd4ad3a4889d9a087c2

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: chafa.py-1.0.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for chafa.py-1.0.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0d8324a02de79395b3832dfc5a3a91ed69435c424f5b1582706b750dca7f3849
MD5 b71fee518e6ee5253dc78e34ad555a06
BLAKE2b-256 42963fd76efa6742ac2f9da34d2ea0fff7a96823406038764dc9c70d04964ed6

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e126d9bab39619deeaf8dbaf4cfebd4c5bc49db2c91224210815e8fd11b82c5
MD5 b2dd3ef57f9d53c8e630f0ae70e33914
BLAKE2b-256 6e9f716cc91af1c204f1dfa26a5b62c624c3c1708abf3ba47c4d0c74998e71d8

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp38-cp38-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp38-cp38-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 4bde698325579f8002b686c90f7cd12e24b310bdac33d48e5f0705fc6c6a0d50
MD5 359077ea93c2ee616ddf25e3cd79abe8
BLAKE2b-256 4ec06b24ddbbb82abb0f9a961bdfc77587417cb3cd49711b0b18b4f1c0860b77

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 910c70a773d1e17451b238c935bad682bb2ee2e78e22281fe9253438fcba9adf
MD5 3c1ce979253bc7c0736ec99f22a3713f
BLAKE2b-256 ddcebcbd36bc0fb4f2a89aba0d33685c4aa41dce0600e46ae95ab73be93f5f2c

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp38-cp38-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp38-cp38-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 0466b56f2646cefc422f9b5aca2dab3ed84de35cc71b2146ed3aafa0b9406105
MD5 6a3e9f2e5e567946fd1ac19382d1487c
BLAKE2b-256 0fe92abb032e7f9bc69658931733c68aac5aea50e8699d346b6a93aa640bb3b9

See more details on using hashes here.

File details

Details for the file chafa.py-1.0.2-cp38-cp38-macosx_10_16_arm64.whl.

File metadata

File hashes

Hashes for chafa.py-1.0.2-cp38-cp38-macosx_10_16_arm64.whl
Algorithm Hash digest
SHA256 3881ba8f8d4268446f7188045e7ecde854503202ab247d67bc051bedd319097e
MD5 71802dea1d1cdf4bed8490d15eaa2464
BLAKE2b-256 2b02939f8faae695b959dec3ec6cc34d73155d1bf82b88b52addc96facebd1e0

See more details on using hashes here.

Supported by

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