Closed ploum closed 4 months ago
Can't you use a LESSOPEN preprocessor to do this conversion? It seems a rather specialized feature to add to less itself.
I’m not really a specialist but I don’t think any preprocessing could help.
The way I see it (which may be wrong) is that the sixel protocol is doing to pixel what ANSI is doing to characters. So any rendering has to be done in less itself (you could not preprocess ANSI).
But I have no idea how hard it could be.
All I know is that I could take the following file and do "cat sixel.txt" in my terminal : it will display a picture.
But "less sixel.txt" is full of garbage.
(I want to be clear that I’m launching a discussion about the subject here because I find it interesting. I have no preconceived opinion on what could or should be done. Thanks a lot for your work on less !)
It already works! :-)
$ xterm -ti vt340
$ wget https://raw.githubusercontent.com/gnachman/libsixel-1/master/images/snake.six
$ less -r snake.six
Oh yeah, with your examples, it works in xterm. That’s really interesting so it seems my own issues are not related to less but probably to the terminal (and also to my own sixels files)
FWIW, the Wikipedia article says sixel sequences begin with ESC P ... q
, but your sixel.txt file seems to be a different format; it contains sequences that begin with ESC _ G
. The snake.six file referred to by @polluks does contain ESC P ... q
sequences.
Based on the message from @ploum on Feb 8, it sounds like this is not a less issue.
Proposal : adding support for images encoded using the sixel format in less. https://en.wikipedia.org/wiki/Sixel
Usecase : Offpunk is a CLI webbrowser which translates HTML pages to ANSI, save the result in a file then open it in less.
Images are converted to ANSI symbols using Chafa. See screenshot on: https://sr.ht/~lioploum/offpunk/
Chafa: https://hpjansson.org/chafa/
Chafa also supports encoding images to the sixel format, which would be a lot less useful but is not supported by less.
Proposal would be to allow less to understand sixel images and display them (probably when enabled using a paramater).
For terminals supporting sixel, see: https://www.arewesixelyet.com/