chafa icon indicating copy to clipboard operation
chafa copied to clipboard

How to avoid extra band with Sixels

Open AmaruCoder opened this issue 1 year ago • 12 comments

Using the option -s, I keep getting a band at one edge of the image. Is this a feature of using Sixels or is it there an option I am missing? See the examples below:

See the green band at the bottom (using -s 50x20):

example1

See the white band on the right (using -s 50x19):

example2

AmaruCoder avatar Oct 14 '24 20:10 AmaruCoder

What does chafa --version say? We've had a bit of back and forth on sixel transparency, since different terminals handle this differently. I think we finally got it right in version 1.14.3.

hpjansson avatar Oct 14 '24 22:10 hpjansson

It says:

Chafa version 1.14.4

Loaders:  GIF JPEG PNG QOI SVG TIFF WebP XWD
Features: mmx sse4.1 popcnt avx2
Applying: mmx sse4.1 popcnt avx2

Copyright (C) 2018-2023 Hans Petter Jansson et al.
Incl. libnsgif copyright (C) 2004 Richard Wilson, copyright (C) 2008 Sean Fox
Incl. LodePNG copyright (C) 2005-2018 Lode Vandevenne
Incl. QOI decoder copyright (C) 2021 Dominic Szablewski

This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

AmaruCoder avatar Oct 15 '24 00:10 AmaruCoder

Looks like a persistent bug, then. Have you tried -t .01 as a workaround?

hpjansson avatar Oct 17 '24 01:10 hpjansson

Also, which terminal are you on?

hpjansson avatar Oct 17 '24 02:10 hpjansson

Thank you. I tried -t .01 but got the same band. I am using iTerm2 Build 3.5.5.

AmaruCoder avatar Oct 18 '24 00:10 AmaruCoder

Thanks. I think this is likely specific to iTerm2 output.

hpjansson avatar Oct 18 '24 11:10 hpjansson

Thank you. My workaround for now is to set the background to black in iTerm2, and use -t 1.0 in Chafa.

AmaruCoder avatar Oct 20 '24 05:10 AmaruCoder

Ok. This works fine on the terminals I have access to on Linux/Windows, and unfortunately I don't have Mac hardware to test with, but I'll look into getting it installed in a VM. I have a few other things to attend to first, though.

In the meantime I have two questions for you:

  • Do transparent sixels from other programs display fine? E.g. lsix, convert with an image with an alpha channel.
  • Does your test case display correctly in other terminals you have access to, if any? E.g. Wezterm.

hpjansson avatar Oct 20 '24 09:10 hpjansson

Thank you for the followup. I don't h ave lsix or convert installed, but I have tested it in Wezterm and it works well. In fact Chafa doesn't need sixel in Weztermn.

AmaruCoder avatar Oct 27 '24 04:10 AmaruCoder

There's a decent chance this is fixed in the master branch now. If testing it is impractical, I recommend trying with the imminent 1.16 release.

hpjansson avatar May 18 '25 17:05 hpjansson

Thank you for keeping an eye on this issue. Unfortunately, the new release (1.16.1) doesn't solve the issue in iTerm (3.5.14).

AmaruCoder avatar Jun 10 '25 23:06 AmaruCoder

FYI, I believe iTerm2 uses libsixel for its sixel decoding, and I don't think libsixel supports transparency. So if chafa is using transparent pixels to pad the image to a cell boundary, it wouldn't surprise me if that doesn't work correctly.

If you don't have access to a Mac to test with, I reckon you could get a good idea of how it's going to turn out by running the output through libsixel's sixel2png utility.

Might also be worthwhile raising an issue on the iIerm2 issue tracker to double check whether I'm correct about it not supporting transparency. I think George maintains a fork of libsixel, so he may even be able to add transparency support.

j4james avatar Jun 11 '25 00:06 j4james