URI:
       timgt - scripts - various script and utils
  HTML git clone git://z3bra.org/scripts
   DIR Log
   DIR Files
   DIR Refs
       ---
       timgt (800B)
       ---
            1 #!/bin/bash
            2 #
            3 # z3bra -- 2014-01-21
            4 
            5 test -z "$1" && exit
            6 
            7 W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay"
            8 FILENAME=$1
            9 FONTH=14 # Size of one terminal row
           10 FONTW=8  # Size of one terminal column
           11 BORDER=20
           12 COLUMNS=`tput cols`
           13 LINES=`tput lines`
           14 
           15 read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY`
           16 
           17 offx=$(($BORDER / $FONTH))
           18 offy=$(($BORDER / $FONTW))
           19 max_width=$(($FONTW * $COLUMNS))
           20 max_height=$(($FONTH * $LINES))
           21 
           22 if test $width -gt $max_width; then
           23     height=$(($height * $max_width / $width))
           24     width=$max_width
           25 fi
           26 if test $height -gt $max_height; then
           27     width=$(($width * $max_height / $height))
           28     height=$max_height
           29 fi
           30 
           31 w3m_command="0;1;$offx;$offy;$width;$height;;;;;$FILENAME\n4;\n3;"
           32 
           33 clear
           34 tput cup $(($height/$FONTH)) 0
           35 echo -e $w3m_command|$W3MIMGDISPLAY
           36 
           37 read -n1 -s
           38 clear