Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

w3m image preview #214

Open
michael-lazar opened this issue Apr 19, 2016 · 17 comments
Open

w3m image preview #214

michael-lazar opened this issue Apr 19, 2016 · 17 comments

Comments

@michael-lazar
Copy link
Owner

I was poking around ranger's source code and there's an extension module (https://github.com/hut/ranger/blob/master/ranger/ext/img_display.py) that apparently makes this incredibly easy.

@professorjamesmoriarty
Copy link
Contributor

Assuming you merge the image branch I seen to the main, I'd love a reminder to add w3m to opt depends for aur package. (once a release is made ofc)

@michael-lazar
Copy link
Owner Author

Yea no problem! It will definitely be an optional setting that will be disabled by default.

BTW do you want to add something to the README about installing on Arch?

@professorjamesmoriarty
Copy link
Contributor

Made PR #215. Not entirely sure what level of detail to cover. Since aur packages arent the same as a "native" package. Feel free to poke at any of the wording. But I think it covers the basics. I'd be happy to change anything.

@michael-lazar
Copy link
Owner Author

Thanks! I moved a few words around to make it more concise but I tried to keep all of your information in there.

@Ziul
Copy link

Ziul commented Apr 26, 2016

I was planning around to uses feh to open direct links of imagens, getting it almost done to ask how it goes for a PR ( diff here as a keep working on it), but playing with w3m would be a much better solution.

@michael-lazar
Copy link
Owner Author

Hi Ziul. I'm making progress with this branch, check it out!

image

Unfortunately I think that the w3m approach is limited because it's not supported on most terminals. Because of that I'm sticking with just thumbnails for now.

@Ziul
Copy link

Ziul commented Apr 27, 2016

Nice! Is there a flag to enable/disable the use of w3m? From rtv.cfg you could get $TERM and check if it's in a whitelist (or not in a blacklist). But the thumbnails looks great!

@professorjamesmoriarty
Copy link
Contributor

I don't think a white or blacklist appraoch is ideal. Rather a feature toggled on/off. Some terminals work, some don't. But it's still a random thing. Ranger users would tell you that it's hit and miss but never set in stone.

@BlitzKraft
Copy link

I use ranger and can confirm that. Although I had partial success with ascii view for images in gnome-terminal.

For me urxvt, and xterm are capable of displaying images in the terminal. gnome-terminal doesn't. However, I still stick with gnome-terminal for its font support.

@Ziul
Copy link

Ziul commented May 25, 2016

@michael-lazar how is going with w3m? I didn't found any environment variable that i could use to call the default image viewer of the user, so i'll set the feh as default on a terrible hard way (xdg-open opens the image with browser. Looks like display can do the trick and is more common than feh, but well... w3m however looks like opens my default image viewer so would be a nice choice, but for it i would wait you to complete. Anyway, i'm letting the PR (#223) opened.

@michael-lazar
Copy link
Owner Author

@Ziul I'll admit that I haven't worked on this lately. It will probably be a while (until I get another burst of motivation) before the w3m stuff gets in. In the mean time, thanks for the PR. I'll go over it and try to get back to you with comments after Memorial Day. As for the default program, @masochist suggested using mailcap here (#78). I haven't tested it thoroughly but you can do something like this

import tempfile
import mailcap
import mimetypes

url = 'http://i.imgur.com/RTMUoFo.png'

mimetype = mimetypes.guess_type(url)[0]
print mimetype

d = mailcap.getcaps()
m = mailcap.findmatch(d, mimetype, 'view', url)
print m[0]

and for me it prints

image/png
feh 'http://i.imgur.com/RTMUoFo.png'

@Ziul
Copy link

Ziul commented May 26, 2016

Great! mailcapwas giving me None, but i did some research and found a work around using part of the answer and the xdg library! Soon i should update the PR with a more generic method. Probably it will offer a option to use vlc on videos too.

@paanvaannd
Copy link

@michael-lazar Any ETA on when we can see the w3m-image-preview branch released? I'm really looking forward to it :+)

@ibrokemypie
Copy link

Is this dead?

@michael-lazar
Copy link
Owner Author

No, but there has been no significant work on it in a few years and no timeline to get it in pushed in at this point.

Anyone is welcome to step in and work on updating the branch, but it would be significant work merging in master and fixing/testing all of the different browser edge cases.

@im-n1
Copy link

im-n1 commented Dec 12, 2018

Hi there I'm glad I see this thread - sort of tho.

It would be really amazing to have image previews because like a half of whole Reddit is image based content. People usually scan the list of threads by eyes pinned onto thumbnails and if they like what they see go onto the thread detail page.

This missing feature is basically one and only thing which is blocking me (and I guess a lot of the others) from switching gtom browser to cli in terms of Reddit.

Althought I already tried to help once with images for a CLI app but sadly got no feedback. From what I know so far (my investigation + info from ranger developer) images in terminal are not easy at all. But once basically any CLI app can solve this we can finally kick asses to those Electron memory-consuming and node-shit apps.

@watzon
Copy link

watzon commented Dec 16, 2019

Just gonna add to this, even though it seems like it may be dead. The kitty terminal supports viewing images natively, without using w3m. It would be wonderful if we could have support for multiple image rendering backends. Personally I prefer kitty, but it would only be available in the kitty terminal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants