rockorager / libvaxis

a modern tui library written in zig
https://rockorager.github.io/libvaxis/
MIT License
497 stars 36 forks source link

Support sixel format for images #79

Open Ratakor opened 2 months ago

Ratakor commented 2 months ago

Support sixel format for images. This can be useful on terminal that don't support kitty graphics but support sixel.

rockorager commented 2 months ago

On Wed Sep 11, 2024 at 7:38 AM CDT, Ratakor wrote:

Support sixel format for images. This can be useful on terminal that don't support kitty graphics but support sixel.

I am very much on the fence about supporting sixels, and leaning towards not supporting them. My preference for these terminals would be to support half-block rendering of images. Yes, the fidelity will greatly suffer however bringing in sixel support is not a small task. Libsixel is not very performant (perhaps that has improved), and I'm hesitant to bring in a C lib on top of that because right now we don't require linking libc.

The very first step would be having a crossplatform zig library that encodes images to sixels.

I'll keep this issue open for discussion.

seityaya commented 4 weeks ago

I can offer my library that I wrote because I saw this message, at the moment it is implemented in C, but for those who know Zig it will not be difficult to port it. https://github.com/seityaya/sixel_c

rockorager commented 4 weeks ago

I can offer my library that I wrote because I saw this message, at the moment it is implemented in C, but for those who know Zig it will not be difficult to port it. https://github.com/seityaya/sixel_c

@seityaya This is looking really good. Do you have any benchmarks compared to libsixel? I know dnkl in particular has been critical of libsixel's performance, and such a simple library in C would be greatly appreciated in many projects.

seityaya commented 4 weeks ago

@rockorager I have not compared the performance of the algorithm with other implementations. In the gif example, a raw 400 by 400 24-bit rgb image is converted to a sixel sequence in one core in ̶0̶.̶1̶ ̶s̶e̶c̶o̶n̶d̶s̶ ̶o̶r̶ ̶1̶0̶ ̶i̶m̶a̶g̶e̶s̶ ̶p̶e̶r̶ ̶s̶e̶c̶o̶n̶d̶. Depending on the palette and the size of the image, this figure can vary widely.

release on and optimisation last commit image 71 images per second