orakaro / rainbowstream

A smart and nice Twitter client on terminal written in Python.
https://github.com/orakaro/rainbowstream
MIT License
3.54k stars 260 forks source link

SIXEL support. #295

Closed peterjschroeder closed 2 years ago

peterjschroeder commented 4 years ago

Support for real images using SIXEL. In rainbow_config.json change "IMAGE_ON_TERM" : true to "sixel". Tested in MLTerm on 2 machines running Debian Sid with different screen sizes. Works correctly.

orakaro commented 3 years ago

Thank you for your effort 👍. Could you provide a testing guidance? I am using a Mac and completely have no idea about SIXEL 🙇‍♂️

peterjschroeder commented 3 years ago

I don't have a mac to test it on, but it looks like iterm2 supports it.

Nithilher commented 2 years ago

I don't have a mac to test it on, but it looks like iterm2 supports it.

I am on mac and use iTerm2. I applied your patch, satisfied the dependencies and - it works!

melroy89 commented 2 years ago

Please merge

orakaro commented 2 years ago

I can't run this PR on my Mac. Changing IMAGE_ON_TERM to sixel results in Sorry, image link is broken

melroy89 commented 2 years ago

I'll give the same answer you gave to somebody else in 2014. Maybe it solves your issue:

sudo apt-get install libjpeg-dev
pip install -I PIL  # inside virtualenv
rainbowstream -iot

Otherwise print the full error log, in order to see what the root cause may be. I now can only guess its maybe related to https://github.com/orakaro/rainbowstream/issues/41#issuecomment-52857511

slarrain commented 2 years ago

I can't run this PR on my Mac. Changing IMAGE_ON_TERM to sixel results in Sorry, image link is broken

I ran into the same issue. For me what fixed it was one of this 2 (can't remember which one, or maybe both):

sudo apt install libsixel-bin
sudo pip3 install libsixel-python

Let us know if that works for you.

Just FYI, I got this patch to work and looks great (my terminal is Wezterm):

image

peterjschroeder commented 2 years ago

libsixel-python is the dependency.

slarrain commented 2 years ago

By the way, the Kitty Terminal Emulator doesn't support sixel. However, it does support its own Image on the terminal implementation. I started playing around and actually got it work (at least on Kitty and on Linux). I think it could be interesting to add support for rendering Image previews on Kitty terminals to rainbowstream.

EDIT: It;s actually working very good. It checks if IMAGE_ON_TERM is not Falseand if your terminal is Kitty, it uses Kitty image rendering implementation. If not, and IMAGE_ON_TERM is sixel, it goes with this PR's implementation. SGR otherwise. If you are interested, I could do a PR, either to @peterjschroeder 's fork or your own @orakaro .

I have not tested it outside of Linux.

melroy89 commented 2 years ago

Kitty

This is a really specific terminal. I never hear about this GPU accelerated terminal emulator. Nice. I currently just use the default xfce4-terminal with bash and Starship Prompt. I expect no issues here with SIXEL.

orakaro commented 2 years ago

Thank everyone for jumping in. Here is my test so far: (Mac Big Sur 11.0.1 / Iterm2 3.5+)

slarrain commented 2 years ago

That is strange, Supposedly, iTerm2 3.0+ is compatible with sixel. Perhaps you could try with wezterm, just to make sure that is not a terminal thing.

Run home and can't see anything

You mean nothing at all or no images? Did you change your config to sixel? If you change it back to True, does it display the ASCII images? Have you been able to debug it at all? For example, on the c_image.py file, is it going inside the sixel if statement?

orakaro commented 2 years ago

Yes, I believe my Iterm version is higher than required.

Perhaps you could try with wezterm,

Will do, thanks.

You mean nothing at all or no images? Did you change your config to sixel? If you change it back to True, does it display the ASCII images?

I see normal tweets, just no images. I changed and confirmed my IMAGE_ON_TERM is sixel. If I change back to True, I can see the ASCII images again.

Have you been able to debug it at all? For example, on the c_image.py file, is it going inside the sixel if statement?

Yes it does. Debugging shows that sixel.getvalue() has value, however sixel.getvalue().decode('ascii') is blank

orakaro commented 2 years ago

Hello, @slarrain wezterm worked absolutely well. Awesome

sixel

Huge thanks to @peterjschroeder for your efforts and everyone for pushing this. I will make this available on PyPi soon