aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/showimg
blob: 38550a6e22a225768843b9306a7f2b04d69c9c0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

[ -z $1 ] && printf "no image given:\n$(echo $0 | tr '/' ' ' | awk '{print $NF}') [Image]\n" && exit

term_width=$(tput cols)
term_width=$(($term_width*8))
term_height=$(tput lines)
term_height=$(($term_height*20))

size=$(identify $1 | awk '{print $3}' | tr 'x' ' ')
width=$(echo $size | awk '{print $1}')
height=$(echo $size | awk '{print $2}')
height=$(($height*$term_width/$width))

if [ $term_height -gt $height ]
then
	$(printf "0;1;0;0;$term_width;$height;;;;;$1\n4;\n3;\n" | /usr/lib/w3m/w3mimgdisplay) &
	read wt && exit
fi

width=$(echo $size | awk '{print $1}')
height=$(echo $size | awk '{print $2}')
width=$(($width*$term_height/$height))

$(printf "1;0;0;0;$width;$term_height;;;;;$1\n4;\n3;\n" | /usr/lib/w3m/w3mimgdisplay) &
read wt && exit