Consider setting background select to 1 by default
I'm referring to the P2 parameter in the sixel_encode_header function here:
https://github.com/saitoha/libsixel/blob/cdae4a88b9c0954adbfa5552e55489afbd934186/src/tosixel.c#L310
My suggestion would be to set that to {0, 1, 0} by default, at least for use in the img2sixel utility.
When you leave P2 as 0, the default behavior is for the terminal to fill the background before outputting any pixels (the idea being that any transparent pixels would inherit that background color). For an image in which all the pixels are set, this serves no purpose, because you're just going to overwrite the background anyway, but it can also have some negative side effects.
-
The background fill occurs before any pixels are output, so when you're using a terminal that supports progressive output, and you're on a slow connection, you can sometimes see the background appear before the full image has loaded. This isn't a big deal for a one-off image, but when it's part of animation it can cause a lot of flickering.
-
When you output an image near the bottom of the screen, the background fill is clamped to the bottom margin to start with. But once the pixel data extends beyond the bottom, and the viewport starts to scroll, the terminal needs to perform an additional fill on any newly revealed rows. When it does that, it just fills the full row height. If your image isn't an exact multiple of the row height, you can then end up with an additional bar of background color below it.
If you've got a real VT330 or VT340 to test with, you can see this effect by first setting the screen mode to reverse video (i.e. \e[?5h), because your background will now be light, while the default sixel background will be black. Here's an example of what it can look like:
Note that I've limited the colors to 6 just to avoid overriding the text foreground and background, otherwise those are likely to be random and the effect isn't always as obvious.
@j4james I appreciate your input --- based on this proposal, I agree that {0, 1, 0} should be the default setting. That said, we’ll probably need to introduce a command-line option or environment variable so users can override it when necessary.