You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
54 lines
1.2 KiB
#!/bin/bash |
|
|
|
#Создан: Пт 29 янв 2016 11:11:27 |
|
#Изменён: Пт 30 июн 2017 22:58:09 |
|
|
|
# Идея z3bra -- 2014-01-21: http://blog.z3bra.org/2014/01/images-in-terminal.html |
|
# Доработка envrm |
|
|
|
W3MIMGDISPLAY="/usr/libexec/w3m/w3mimgdisplay" |
|
FONTH=12 # Size of one terminal row |
|
FONTW=8 # Size of one terminal column |
|
COLUMNS=`tput cols` |
|
LINES=`tput lines` |
|
|
|
#Все позиции захардкорены |
|
posx[1]=750; posx[2]=750 |
|
posy[1]=100; posy[2]=100 |
|
|
|
row[1]=0 |
|
|
|
x=1 |
|
y=1 |
|
img=1 |
|
images=24 |
|
|
|
FILENAME="$1" |
|
|
|
clear |
|
|
|
#Обработка только изображений |
|
file "$FILENAME" | grep 'JPEG|PNG|GIF' 2>&1 >/dev/null |
|
|
|
if [ $? -eq 0 ]; then |
|
read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY` |
|
|
|
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;${posx[x]};${posy[y]};$width;$height;;;;;$FILENAME\n4;\n3;" |
|
|
|
tput cup $((($height+${row[y]})/$FONTH)) ${text[$((x-1))]} |
|
echo -n -e $w3m_command|$W3MIMGDISPLAY |
|
fi |
|
|
|
|