danielgatis / imgcat

Display images and gifs in your terminal.
MIT License
199 stars 11 forks source link

Imgcat and Vifm #3

Closed jiDOK closed 3 years ago

jiDOK commented 3 years ago

Thanks a lot for Imgcat! It's the only way I have found to preview images in a Windows command prompt.

I am trying to get Imgcat and Vifm work together on Windows 10, using Imgcat to show images in Vifm's preview pane.

Imgcat works fine by itself in cmd prompt but it does not seem to work from Vifm, producing the error message: failed to get the console state: The handle is invalid.

Since I wasn't sure where the problem is rooted, I first asked over at Vifm. From what I understand Vifm expects some kind of output while Imgcat prints directly to the console.

A workaround was tried but didn't help. Here's the Question over at Vifm's github for reference: https://github.com/vifm/vifm/issues/671

I am not sure if it is possible on Windows at all, but could Imgcat be made to give Vifm the right output somehow?

danielgatis commented 3 years ago

can you provide a simple vimrc with Vifm and imgcat configured?

danielgatis commented 3 years ago

I pushed a new version with this fix: 9e5d4ab673487c09139a705e425d050cd5a37365.

Can you do a test with this version https://github.com/danielgatis/imgcat/releases/tag/v1.0.6?

jiDOK commented 3 years ago

I'm not at home, but will do later and report, thanks!

jiDOK commented 3 years ago

It seems to be close, but not quite!

I have this in the vifmrc:

fileviewer {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm}
         \ imgcat %"c

and I get this result: Imgcat01 while it should look like this: Imgcat02 Edit: using %pd does not work, result is a lot of text in the console after closing Vifm.

danielgatis commented 3 years ago

looks like the true colors are not supported

jiDOK commented 3 years ago

Oh, I see. Xaizek wrote over at Vifm: "I looked at imgcat again and it prints 24-bit escape codes, which Vifm doesn't interpret. So if requirement about output being directly to the console is lifted, you'll still need to add %pd." Sounds like this is related?

danielgatis commented 3 years ago

Oh, I see. Xaizek wrote over at Vifm: "I looked at imgcat again and it prints 24-bit escape codes, which Vifm doesn't interpret. So if requirement about output being directly to the console is lifted, you'll still need to add %pd." Sounds like this is related?

yep! You need to add support to 24-bit color on Vifm to make it works.

jiDOK commented 3 years ago

So from what I understand it is not easily possible to add 24-bit color support because of the library Vifm uses on Windows (PDCurses). (Xaizek's answer is in the Vifm-Issue I linked at the top)

So unless you want to add an 8-Bit color mode it's just not compatible on Windows. Since that probably would be a bigger feature request, I'll close the Issue. Thank you for your help!