tulir / gomuks

A terminal based Matrix client written in Go.
https://maunium.net/go/gomuks
GNU Affero General Public License v3.0
1.35k stars 120 forks source link

Render images on supported terminals. #103

Open ghost opened 5 years ago

ghost commented 5 years ago

Certain terminals, such as Kitty, support rendering images inside the terminal. In these conditions I think the image should be rendered.

r3k2 commented 5 years ago

+1

abrahimladha commented 5 years ago

Ranger supports this by making w3m do all the work with w3mmingdisplay. If gomuks follows a similiar idea, it might not be too hard to implement.

foresto commented 3 years ago

Related: The vte library recently added sixel graphics support, so terminal programs built with that library will probably have it before long. This includes gnome-terminal, xfce4-terminal, and others.

Tycho-S commented 2 years ago

Sorry for opening a duplicate earlier, I closed it already.

I found another library in go that can do this (unlike vte that's in C++) https://github.com/BourgeoisBear/rasterm

Additionally to sixel it can also use the kitty protocol. One thing it doesn't do is block rendering like the current library though, sadly. So both would have to be used for fallback.

autoteelar commented 1 year ago

i second this, urxvt works perfect with w3m-img

Aleksanaa commented 1 year ago

https://github.com/mattn/go-sixel That's a go module

reynoldsme commented 1 year ago

As far as I understand, before any high resolution image format can be included in-band in gomuks it will need to be implemented in the tcell TUI library that gomuks uses. There is an open PR https://github.com/gdamore/tcell/pull/436 that exposes interfaces in tcell to implement arbitrary graphics protocols as plugins and the PR author has a really cool demo showing a tcell sixel implementation. https://github.com/diamondburned/tcell-sixel Unfortunately, there doesn't seem to have been any activity on the PR recently.

I say "in-band" meaning, the images are sent by the application and displayed directly by the terminal emulator, because there is an alternative "out-of-band" approach, but it has downsides.

w3m-img https://packages.debian.org/sid/w3m-img and ueberzugi (now unmaintained) https://github.com/seebye/ provide raster images support by drawing over a terminal window via an external process. This bypasses the need for the terminal and and TUI library to directly support an image protocol, but doesn't work by default over SSH, and requires that the image drawing implementation support specific OSs and display managers.

https://github.com/mattn/go-sixel appears to work great for encoding sixel images, but at the moment there doesn't seem to be a good way to output those images in the gomuks UI.

ferdinandyb commented 1 year ago

There's also another approach to adding sixels to tcell since 436: https://github.com/gdamore/tcell/pull/602. Fingers crossed for some implementation to happen :)

deonspengler commented 1 year ago

I see gdamore/tcell#602 has now been merged. Could someone please point me in the right direction with regards to gomuks, which source file currently handles the displaying of the ansi image. I would like to see if I get sixel to work in gomuks.

reynoldsme commented 1 year ago

I see gdamore/tcell#602 has now been merged. Could someone please point me in the right direction with regards to gomuks, which source file currently handles the displaying of the ansi image. I would like to see if I get sixel to work in gomuks.

https://github.com/tulir/gomuks/blob/master/ui/messages/filemessage.go#L179

deonspengler commented 1 year ago

I see gdamore/tcell#602 has now been merged. Could someone please point me in the right direction with regards to gomuks, which source file currently handles the displaying of the ansi image. I would like to see if I get sixel to work in gomuks.

https://github.com/tulir/gomuks/blob/master/ui/messages/filemessage.go#L179

Thanks, I will give this try. First time working with go, I normally code in python.

r3k2 commented 1 year ago

any news on this? :)

deonspengler commented 1 year ago

I have not made any progress, still getting the hang of the go langue.

benmordecai commented 11 months ago

Another option may be to use ueberzugpp the way that ytfzf does for thumbnails

coderkun commented 5 months ago

The problem I have is that the mauview library does not support this. The currently implementation is based on chars via the SetContent() function but for Sixel we would need a separate method that uses something the following code (from the Sixel demo):

 // Move the cursor to our draw position
ti.TPuts(tty, ti.TGoto(sixelX, sixelY))
// Draw the sixel data
ti.TPuts(tty, img.data.String())