-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use the new image preview function #82
Comments
Hi, it won't work out of the box, that script was mentioned more for reference and needs some changes. Modified version of the script (it lacks arguments checks, though): #!/bin/bash
#
# z3bra -- 2014-01-21
W3MIMGDISPLAY="/usr/libexec/w3m/w3mimgdisplay"
FONTH=15 # Size of one terminal row
FONTW=8 # Size of one terminal column
X=$1
Y=$2
COLUMNS=$3
LINES=$4
FILENAME=$5
read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY`
x=$(($FONTW * $X))
y=$(($FONTH * $Y))
max_width=$(($FONTW * $COLUMNS))
max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt
if test $width -gt $max_width; then
height=$(($height * $max_width / $width))
width=$max_width
fi
if test $height -gt $max_height; then
width=$(($width * $max_height / $height))
height=$max_height
fi
w3m_command="0;1;$x;$y;$width;$height;;;;;$FILENAME\n4;\n3;"
echo -e $w3m_command|$W3MIMGDISPLAY Note that you need to specify font width and height in pixels in the script. Full path to Sample command for fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
\ imgt %px %py %pw %ph %c If you use terminal multiplexer offset of current window should be added to coordinates in the script. Also it won't work in all terminals, but works fine at least in xterm. |
Hello, I installed Here is how trace of the script looks like: W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay"
#7: W3MIMGDISPLAY=/usr/lib/w3m/w3mimgdisplay
FONTH=15 # Size of one terminal row
#8: FONTH=15
FONTW=8 # Size of one terminal column
#9: FONTW=8
X=$1
#11: X=115
Y=$2
#12: Y=2
COLUMNS=$3
#13: COLUMNS=109
LINES=$4
#14: LINES=50
FILENAME=$5
#15: FILENAME=Folder.jpg
read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY`
#17: read width height
echo -e "5;$FILENAME" | $W3MIMGDISPLAY
#117: echo -e '5;Folder.jpg'
#117: /usr/lib/w3m/w3mimgdisplay
x=$(($FONTW * $X))
#19: x=920
y=$(($FONTH * $Y))
#20: y=30
max_width=$(($FONTW * $COLUMNS))
#22: max_width=872
max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt
#23: max_height=720
if test $width -gt $max_width; then
height=$(($height * $max_width / $width))
width=$max_width
fi
#25: test -gt 872
#/usr/local/bin/imgt: line 25: test: -gt: unary operator expected
if test $height -gt $max_height; then
width=$(($width * $max_height / $height))
height=$max_height
fi
#29: test -gt 720
#/usr/local/bin/imgt: line 29: test: -gt: unary operator expected
w3m_command="0;1;$x;$y;$width;$height;;;;;$FILENAME\n4;\n3;"
#34: w3m_command='0;1;920;30;;;;;;;Folder.jpg\n4;\n3;' Could I ask for your help? any hints? |
Hi @fogine, are you sure the path to You could try running failing command just in a terminal, e.g.
It should print image size if file exists in current directory. |
Thanks @xaizek for quik reply, But if I run
and if I run:
Which results to empty output.... |
Maybe try other formats like PNG in case w3m is missing some dependencies. Also, do you see images in w3m (e.g. if you do |
I tried several images in different format as well. I got same empty result. Xubuntu 14.04 x64, |
Works fine in native console.
Yes, xterm ( $ w3m --version w3m version w3m/0.5.3, options lang=en,m17n,image,color,ansi-color,mouse,gpm,menu,cookie,ssl,ssl-verify,external-uri-loader,w3mmailer,nntp,gopher,ipv6,alarm,mark |
At least original question is answered, other issues should be treated separately. Finally moved this information to wiki page. |
Hi,
I have discovered the new w3m image preview functionality. I have copied the bash script from the site referenced and made it reachable from vifm.
Problem is that the image overlays my left browsing pane while the right one is the preview pane.
I have tried to guess how things work, but I would be very very happy if I could get some help on putting the image properly into the preview pane at the right.
I can see my pictures, but in the wrong place.....
The text was updated successfully, but these errors were encountered: