image integration and sixel support #94
Replies: 15 comments 15 replies
-
Hey, I turned this into a discussion (it's easier for me to keep track). Thanks for explain the different ways to represent an image in the terminal. I wasn't aware about sixel, I will do some reading to understand how it works and get back to you on it. For the basic string representation, that should just work since it is a string. Not sure if it's something worth looking into, but one thing to improve the image visualization is to use the half-block unicode character: ▄ instead of █. This allows you to set the color of character and the background differently so that you have to shades in the same line. That's what I did to make the colors in the image in the README, see here. Also Term and most terminal support a lot more colors now so you could use that to create something more faithful to the original image. Either way, any string representation should just work, I need to look into sixel. I'll get in touch in a bit! |
Beta Was this translation helpful? Give feedback.
-
I'll try to have a look into this too. |
Beta Was this translation helpful? Give feedback.
-
Btw, I don't do C, but apparently there's a |
Beta Was this translation helpful? Give feedback.
-
For xterm encoding/decoding improvement, maybe the best way to push the progress is to steal JuliaImages/ImageInTerminal.jl#62 and make a new repo, expose a simple encoding/decoding interface (such as Sixel.jl does) without interweaving with the REPL, show, or display thing. I really hope I can do it myself but it seems that I'm always busier than I thought. |
Beta Was this translation helpful? Give feedback.
-
Okay, I've done my homework including reading this detailed explanation about sixel syntax: https://vt100.net/shuford/terminal/all_about_sixels.txt My understanding is that sixel is rendered through some terminal "magic", but it's different from the way text is handled in the terminal. E.g. when I try to select the image: compared to the basic image encoding: as such, I don't think it can work with Term, since I can't figure out a way to manipulate it as you would a sequence of characters and ANSI escape codes. Do you have any idea of how that would work? So image integration should work out of the box, but I can't see how sixel would fit with all this unfortunately? |
Beta Was this translation helpful? Give feedback.
-
I could nest a sixel image into a frame in JuliaPlots/UnicodePlots.jl#196, but it feels hacky. |
Beta Was this translation helpful? Give feedback.
-
In |
Beta Was this translation helpful? Give feedback.
-
I see, that should work then, very clever. Term uses segments which are basically lines of text with applied styling (ANSI code). So a So one way to do it would be to split each line of the sixel into a "segment, and then edit the segment printing such that if the segment include sixel code it does the magic printing discussed above.
So I guess the first thing would be figure out: how to split sixel into lines, how the width of the lines and if each sixel line can have |
Beta Was this translation helpful? Give feedback.
-
I'm not sure if this helps:
A trick that might be work is to send a test image with known size to the terminal, The DCS control sequence |
Beta Was this translation helpful? Give feedback.
-
Looks like Thus, it looks like the surface occupied by the sixel sequence is approximately julia> using TestImages
julia> img = TestImages.shepp_logan(50)
[...]
julia> cols = ceil(Int, 50 / 7)
8
julia> rows = ceil(Int, 50 / 15)
4 |
Beta Was this translation helpful? Give feedback.
-
This all looks doable, I guess the only question is who's going to do it? :) |
Beta Was this translation helpful? Give feedback.
-
Just a small update on this, Term.jl will support Markdown rendering: https://twitter.com/Federico_claudi/status/1535034402018934784?s=20&t=MrkwTIrk35NTE33r0MdQaA though of course it wouldn't handle images yet: sixel support would fix that. |
Beta Was this translation helpful? Give feedback.
-
For @johnnychen94, these PRs seem to have stalled: do you know what is preventing going forward ? |
Beta Was this translation helpful? Give feedback.
-
Hi there (comming from Textualize/rich#384) I commented on a few things above, maybe this helps to get sixel support rolling. What I currently wonder about - how do you create the sixel data in the first place, with which encoding lib? |
Beta Was this translation helpful? Give feedback.
-
@jerch, thanks for your valuable comments (and pointing the
We use https://github.com/JuliaIO/Sixel.jl, a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, we have two image encoding strategy in Julia:
Which prints the encoded string like this -- UnicodePlots also take the direct lookup table method
It seems that Term's Panel supports the "basic" encoding very well, while not working well with the Sixel sequence:
cc: @t-bltg @soumitradev
Beta Was this translation helpful? Give feedback.
All reactions