normen / whatscli

A command line interface for WhatsApp
589 stars 46 forks source link

[Feature Request] Add SIXEL support for images on the Terminal #68

Open slarrain opened 2 years ago

slarrain commented 2 years ago

Given that more and more WhatsApp conversations are filled with images or GIFs, I would like to request a feature that would allow the user to be able to see the images on the terminal, inline.

This is different than ASCII support, because:

  1. The idea is that you don't have to press s nor navigate to the message to show the image.
  2. It would be a real Image and not an ASCII one.

What I am thinking is pretty much the same functionality that was implemented with this PR on Rainbowstream (it even has screenshots). I know in Python it would not be hard to implement, but in Go I have n idea how hard it would be. I hope is doable.

Thanks!

normen commented 2 years ago

This functionality of some terminals basically works by sending special ANSI escape messages to the terminal that contain the image data.

In whatscli, currently the output of the image display command is parsed for ANSI messages to convert the colors to tview colors for the message display window. See https://github.com/normen/whatscli/blob/ae25296b9d47087af72e561ce80a8382e9dbf7cc/main.go#L567

The tview widgets themselves do not seem to support this kind of ANSI message, when I use iTerm2's imgcat tool and remove the ANSI conversion in the code above I still only get the raw data instead of the image. So you'd have to find a way to directly send these to the terminal and at the same time make sure its anchored in the tview text widget. Not sure if and how this is possible

The way this should be implemented for the user is by adding an option like CommandRawAnsi and based on that decide how to handle the image view command output.

A PR is welcome but I don't think I'll start working on this personally.