felix icon indicating copy to clipboard operation
felix copied to clipboard

Native support for the image preview

Open kyoheiu opened this issue 1 year ago • 6 comments

Currently we need chafa to preview image files, but #186 enables it out of the box, using viuer. The problem is, that with viuer the preview of gif animation could take a long time, which is really frustrating. This leads to not supporting high-res preview in both iTerm and kitty protocol. Reading gif as Frames via image crate would be a solution.

kyoheiu avatar Feb 24 '23 20:02 kyoheiu

viuer's sixel feature does not work on runtime because sixel-sys doesn't provide its own compiled libsixel library: cf. https://github.com/AdnoC/sixel-sys/issues/3 This library seems unmaintained for years.

kyoheiu avatar Mar 01 '23 01:03 kyoheiu

feature-viuer branch can show the image preview by blocks in any terminal, and if your terminal supports iTerm protocol, even the high-res one. But Many terminals are with libsixel, which is not easily used in Rust code because of the issue above. I think many user wants the high-res preview if available, so this branch is not completed. I leave this issue open to show the process. In the current version chafa supports the image preview in felix.

kyoheiu avatar Mar 01 '23 01:03 kyoheiu

Refactored the image preview flow: Now in feature-viuer branch it is supported by default, and if your terminal implements iTerm protocol (i.e. Wezterm) it can show the high-res image. Furthermore, if your terminal supports sixel or kitty protocol, by installing chafa you have the high-res preview.

kyoheiu avatar Mar 04 '23 08:03 kyoheiu

Is there any chance that this could work using Tmux & Kitty?

Using Kitty as-is does work perfectly, I get images in high resolution using Chafa.

Using Tmux within Kitty does not work. I'm not sure to understand the intricacies of how does Chafa or those so-called Kitten for displaying images work, but I guess Tmux does something that prevents this behavior.

Do you think that this could be added to Felix? If not, can you explain ways to make it work or alternatives?

Looks like it is something about a multiplexer passthrough using Kitty & Tmux as discussed here https://github.com/hpjansson/chafa/issues/162

Thank you!

aminnairi avatar Jan 02 '24 11:01 aminnairi

Just chiming in to note that tmux passthrough should indeed be working on Chafa master. It will be in the 1.14.0 release in a couple of days. Cheers!

hpjansson avatar Jan 03 '24 00:01 hpjansson

Refactored the image preview flow: Now in feature-viuer branch it is supported by default, and if your terminal implements iTerm protocol (i.e. Wezterm) it can show the high-res image. Furthermore, if your terminal supports sixel or kitty protocol, by installing chafa you have the high-res preview.

I'm on Windows. When I try to build this branch to get iterm previews I get the error:

user@host MINGW64 ~/repos/felix (feature-viuer)
$ cargo install --locked --path .
  Installing felix v2.3.0 (C:\Users\user\repos\felix)
    Updating git repository `https://github.com/kyoheiu/syntect`
error: failed to get `syntect` as a dependency of package `felix v2.3.0 (C:\Users\user\repos\felix)`

Caused by:
  failed to load source for dependency `syntect`

Caused by:
  Unable to update https://github.com/kyoheiu/syntect#b5212417

Caused by:
  failed to clone into: C:\Users\user\.cargo\git\db\syntect-efeee53e6df11ed1

Caused by:
  failed to authenticate when downloading repository

  * attempted to find username/password via git's `credential.helper` support, but failed

  if the git CLI succeeds then `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  failed to acquire username/password from local configuration

I'm able to build the main branch fine however. I'm using Wezterm and have chafa but the image previews don't display with sixel for some reason. So, I was looking to use iterm.

RioNight avatar Jan 05 '24 04:01 RioNight