chafa icon indicating copy to clipboard operation
chafa copied to clipboard

Python bindings

Open hhoeflin opened this issue 3 years ago • 2 comments

This library looks great. I was wondering if there is a python package available that wraps this? Would be great to have picture previews directly in the python terminal!

hhoeflin avatar Dec 22 '20 07:12 hhoeflin

That would be interesting. I used to call the chafa binary program from os.system in some of my python programs.

cdluminate avatar Dec 22 '20 10:12 cdluminate

There are no Python bindings that I know of, but it'd be great to have. If you want get the ball rolling on this, I'll support it any way I can.

The C API is documented here: https://hpjansson.org/chafa/ref/

A first pass wouldn't have to cover everything, just enough to support a canvas and the most important options (like ChafaCanvasMode, ChafaPixelMode and geometry).

hpjansson avatar Dec 22 '20 14:12 hpjansson

Here we go! GuardKenzie/chafa.py

I have been working on this during December and I think it's time for a proper release. You can also check out the homepage on chafapy.mage.black which includes instructions on getting started, some examples and a tutorial.

It is almost up to feature parity with Chafa, it is missing

  • Emitting control sequences
  • Adding, getting and using built in glyphs with symbol maps.
  • Setting getting and emitting terminal sequences
  • Using raw color in the canvas

GuardKenzie avatar Jan 07 '23 18:01 GuardKenzie

@GuardKenzie Wow, I am completely blown away by this. Thank you so much!

How would you like to proceed -- I'm thinking we can close this issue now and collaborate in your repo/discussions?

hpjansson avatar Jan 09 '23 02:01 hpjansson

Yeah, that sounds amazing!

GuardKenzie avatar Jan 09 '23 09:01 GuardKenzie

Closing -- to be continued in https://github.com/GuardKenzie/chafa.py/discussions

hpjansson avatar Jan 09 '23 19:01 hpjansson