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
Support for tmux? #65
Comments
Hello!
Well... that's because the image is represented using Unicode blocks with ANSI color escape sequences. In other words, what you're seeing is basically colored text. This is called the "block" render style within the context of this project.
Well... Tmux itself doesn't support any graphics protocol, cos it just technically can't but there might be a way forward, I'll get to that in a moment.
The iTerm2 inline image protocol is implemented by the iTerm2 terminal emulator (the GUI program whose icon shows on your dock). Tmux is a terminal multiplexer... basically, that means a program that provides and manages multiple terminal sessions within another terminal emulator. Tmux intercepts escape sequences interpretes them and decides if and how they should be passed on to the actual terminal emulator. Now, the problem is Tmux doesn't implement/support the image protocol i.e it can not understand the escape sequences used by the image protocol. By default,
Well... more of a workaround. I've known about this for a while and had it in mind to add support for this but I've been reluctant to do so because it's a "workaround" meaning many things won't work as expected... e.g images won't scroll along with text as they normally would within the actual terminal emulator, amongst other issues. The best option you have (and my advice) is to use use the terminal emulator directly and I'll recommend Kitty, it probably has most of the features of Tmux you need. Please note that I'm not promising support for Tmux passthrough, I'm still evaluating the situation and at the moment, the cons outweigh the pros. Thank you! |
You're welcome 😃 I'll look more into and actually test it out soon i.e support for Tmux passthrough... I'll keep this issue open till then. If I do add support at some point in the future, I'll simply note the quirks and maybe add some tips on how to best use it without much issues. Once again, thanks for the suggestion. |
By the way, I'll add support for matplotlib backend and IPython magic soon. I just thought I should let you know cos they might be useful to you. 😃 |
Hi thanks for your sincere help! I am very delighting to see these new features! I really like term-image, an awesome tool!
I know I can use fig.savefig() to a file, a use from file() to read it back and then draw this image() |
I personally don't use matplotlib but I'll look around and get back to you. In the mean time, you can simply save the image to a buffer instead of a file i.e import io
from PIL import Image
from term_image.image import AutoImage
buf = io.BytesIO()
fig.savefig(buf)
image = AutoImage(Image.open(buf)) I don't think there'll be any significant performance difference but it'll help avoid writing to disk. |
Hi thank your for your reply. I found a solution that seems to be much faster than savefig as the answer said (2ms vs 35~40ms) |
Yeah, thanks. Beware though... only the AGG backend(s) implement(s) the from matplotlib.backends.backend_agg import FigureCanvasAgg
canvas = fig.canvas if isinstance(fig.canvas, FigureCanvasAgg) else FigureCanvasAgg(fig) After spending some time going through the package's docs (and a little through the source code) yesterday... I found I had not yet mentioned it because I'm yet to test it but I plan to use this in implementing a |
Now, back to the issue at hand... After reading through https://gitlab.com/gnachman/iterm2/issues/3898 with some experimentation and thought... I've come to conclude that tmux support for any graphics-based style just isn't workable. One could make the image display, no much problem with that... but due to the fact that tmux is in no anyway aware of the image or it's size, the whole thing becomes literally useless and in some cases even problematic. See also: kovidgoyal/kitty#2457 A few amongst the problems I've realised are:
In short... Terminal multiplexers are a pain in the ass... if you need terminal graphics, simply use the terminal emulators that support them! :( Thank you! 😃 |
Thanks a lot for your valuable advice! I will listen to you! |
Hi, I am using tmux. The left pane is my vim pane writing python, the right is ipython pane. When I use term-image's image.show() funtion. A very vague image printed in the right pane. how to make it more sharp? thx
The text was updated successfully, but these errors were encountered: