-
Notifications
You must be signed in to change notification settings - Fork 97
Support OR mode which is enabled by -O, --ormode option. #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Here is more detailed information |
|
I intend to incorporate this new feature eventually. However, since updates to the documentation, Python interface, and shell completion scripts are also required, I will first work on it in a separate branch. Once all components are ready, I plan to merge it into the master branch. |
|
@arakiken On several test images (e.g., images/egret.jpg), the output ends up larger than when encoded with -Esize. On average I’m seeing a 30-40% reduction, but in about 25% of cases the file size actually increases. |
|
@arakiken I’d like to start by offering this as a build-time option (default off), document it, and then gauge whether experts and terminal emulator authors will accept it. |
|
It's worth noting the VT330 uses a form of OR mode in it's Sixel implementation (possibly XOR - I'm not certain of the details). So if I were going to implement something like this in a terminal, I would prefer an algorithm that was compatible with the VT330, as that way it could potentially also be used to support legacy VT330 apps. But that requires that the mode can be enabled independently of the image format, e.g. with something like a Another benefit of a |
|
I think DECSET has the downside that the application must restore terminal state itself. |
|
I don't think that's a real issue. Any major TUI application is going to be restoring modes that would be far more critical than this (e.g. mouse modes, keyboard modes, alt screen mode). And if it was really a concern, you could always incorporate the mode settings along with your image sequence so you don't have to worry about it later, e.g. something like this: That said, I think the bigger challenge would getting this mode compatible with the algorithm that DEC used, so I doubt my implementation would end up being interoperable with this anyway. So feel free to ignore the mode suggestion - it was just an idea. |
|
@j4james It may not be a practical problem, and there’s precedent: chafa’s sixel output prepends CSI ? 25 l to hide the cursor. That said, I have concerns: a sixel stream is a large control sequence, and if output is interrupted by SIGINT, the application must handle the signal and restore the terminal state itself. Another issue is that inserting any sequence before DCS makes it harder for tools to recognize the data as sixel; for example, img2sixel only treats input as sixel when the file begins with DCS. |
I still don't think this is a big problem. Even if the terminal is left with the mode enabled, you probably wouldn't notice. I expect most Sixel images don't overwrite pixels in a way that would be affected by this mode.
I assume in this scenario that the app would have explicitly requested the OR encoding when calling img2sixel, so it should know the response could start with that prefix. And if you weren't expecting that encoding, you wouldn't be able to process the data meaningfully anyway. But as I said before, I don't think this is going to be interoperable with the DEC format anyway, so it doesn't matter to me how you decide to enable it. I only really cared when I thought there was a chance it might be compatible. |



I would like to add -O option to img2sixel.
It enables "ormode" extension of Sixel Graphics.
"ormode" is originally devised by https://twitter.com/isaki68k and https://twitter.com/moveccr for NetBSD/x68k.
Please read http://www.pastel-flower.jp/~isaki/NetBSD/osc16hi/page40.html and https://github.com/isaki68k/sayaka/blob/master/vala/sixel.native.c#L133 for more information.