Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
previewing image with ranger [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Biloute
Guru
Guru


Joined: 03 Apr 2008
Posts: 301
Location: LENS

PostPosted: Sat Mar 02, 2013 3:32 pm    Post subject: previewing image with ranger [solved] Reply with quote

Ranger 1.6.0 is now in portage tree.
I want to add the feature to draw images inside the console using w3mimgdisplay.

Anyone can give me help?

Code:
www-client/w3m-0.5.3-r1 USE="X imlib nls ssl unicode -fbcon -gpm -gtk -lynxkeymap -migemo -nntp -xface"
app-misc/ranger-1.6.0 PYTHON_TARGETS="python2_7 python3_2 python2_6 python3_1"
x11-terms/mrxvt-0.5.4 USE="jpeg png session truetype -debug -menubar -utempter -xpm"


Code:
cat .config/ranger/rc.conf
set preview_image true
ranger --copy-config=scope

_________________
Gentoo rocks


Last edited by Biloute on Mon Mar 25, 2013 8:20 am; edited 1 time in total
Back to top
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2247

PostPosted: Sun Mar 03, 2013 3:27 am    Post subject: Reply with quote

Biloute ...

Looking at 'scope.sh' ranger doesn't use 'w3mimgdisplay' but 'img2txt', from media-libs/libcaca, for displaying 'text' previews of images.

scope.sh
Code:
# Ascii-previews of images:
image/*)
    img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;;

I have this feature disabled as a 'end' (right arrow) will open the image in 'feh' (or similar image viewer), but if libcaca is installed the following should enable it:

Code:
set preview_script ~/.config/ranger/scope.sh
set use_preview_script true
set preview_images true

best ... khay
Back to top
View user's profile Send private message
r5d3
n00b
n00b


Joined: 08 Mar 2013
Posts: 1

PostPosted: Fri Mar 08, 2013 10:40 pm    Post subject: Reply with quote

If you install w3m with use flag "imlib" w3mimgdisplay will be installed in /usr/libexec/w3m/.

However, it seems ranger searches for w3mimgdisplay in /usr/lib/w3m/.

The following did the job for me:

Code:
mkdir /usr/lib/w3m
ln -s /usr/libexec/w3m/w3mimgdisplay /usr/lib/w3m/w3mimgdisplay

Furthermore I need to run ranger with python:2.7

Code:
ranger-python2.7

With python-3.2.3 I get the error message

Quote:
'str' does not support the buffer interface

when I select an image.
Back to top
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2247

PostPosted: Sat Mar 09, 2013 9:48 am    Post subject: Reply with quote

Biloute, r5d3 ...

I looks like both the X and imlib useflags are needed. Anyhow, the above path can be patched with user patch ... add the following to /etc/portage/patches/app-misc/ranger

ranger-1.6.0-img_display.patch
Code:
diff -rupN ranger-1.6.0.orig/ranger/ext/img_display.py ranger-1.6.0/ranger/ext/img_display.py
--- ranger-1.6.0.orig/ranger/ext/img_display.py   2013-02-22 23:36:30.000000000 +0100
+++ ranger-1.6.0/ranger/ext/img_display.py   2013-03-09 10:26:48.683328687 +0100
@@ -13,7 +13,7 @@ w3m need to be installed for this to wor
 import termios, fcntl, struct, sys
 from subprocess import Popen, PIPE
 
-W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay'
+W3MIMGDISPLAY_PATH = '/usr/libexec/w3m/w3mimgdisplay'
 W3MIMGDISPLAY_OPTIONS = []
 
 class ImgDisplayUnsupportedException(Exception):

I'll submit this as a bug as and when I get time ...

best ... khay
Back to top
View user's profile Send private message
Biloute
Guru
Guru


Joined: 03 Apr 2008
Posts: 301
Location: LENS

PostPosted: Wed Mar 13, 2013 6:50 pm    Post subject: Reply with quote

r5d3 It doesn't work for me.
I use mrxvt and the default scope.sh
What is your terminal?
_________________
Gentoo rocks
Back to top
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2247

PostPosted: Thu Mar 14, 2013 11:23 am    Post subject: Reply with quote

Biloute ...

I'm not exactly sure what the issue is but if I try and test this I get "failed to execute w3imagedisplay". Which is basically the img_display.py failing:

Code:
raise Exception('Failed to execute w3mimgdisplay')

This suggests some part of the script isn't working as it should. See: /usr/lib/python2.7/site-packages/ranger/ext/img_display.py

BTW, I tested with urxvt and this is listed as a terminal which the script had been tested.

best ... khay
Back to top
View user's profile Send private message
jabbat
n00b
n00b


Joined: 23 Mar 2013
Posts: 2

PostPosted: Sun Mar 24, 2013 9:39 am    Post subject: Reply with quote

Hi,

Any success?

Thanks,
Alexey.
Back to top
View user's profile Send private message
Biloute
Guru
Guru


Joined: 03 Apr 2008
Posts: 301
Location: LENS

PostPosted: Sun Mar 24, 2013 12:14 pm    Post subject: Reply with quote

No success

I play with rxvt-unicode-9.16 to get some news
_________________
Gentoo rocks
Back to top
View user's profile Send private message
jabbat
n00b
n00b


Joined: 23 Mar 2013
Posts: 2

PostPosted: Sun Mar 24, 2013 9:47 pm    Post subject: Reply with quote

Hi Biloute,

Found out that I followed same steps r5d3 has mentioned.
Works for me both in xterm and urxvt, python2.7
1. Edited the /usr/lib/python2.7/site-packages/ranger/ext/mg_display.py:

W3MIMGDISPLAY_PATH = '/usr/libexec/w3m/w3mimgdisplay'

2. Changed python version
eselect python set python2.7

Hut posted to Archlinux thread regarding the
Code:
TypeError: 'str' does not support the buffer interface
Seems like he's talking about this fix though it doesn't work for me with python3.2

Also in next build we should be able to export the W3MIMGDISPLAY_PATH due to bug #38582.

Thanks,
Alexey.
Back to top
View user's profile Send private message
Biloute
Guru
Guru


Joined: 03 Apr 2008
Posts: 301
Location: LENS

PostPosted: Mon Mar 25, 2013 8:22 am    Post subject: Reply with quote

Thanks to all.

It's ok with rxvt-unicode and ranger-python2.7
_________________
Gentoo rocks
Back to top
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2247

PostPosted: Mon Mar 25, 2013 3:27 pm    Post subject: Reply with quote

Biloute wrote:
It's ok with rxvt-unicode and ranger-python2.7

Biloute ... thats odd because that is the exact same configuration I used above, with the patch to fix the path to w3mimgdisplay, and it didn't work (see above error).

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum