tTerminal image viewer - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit e7fcb9c2d72e09a521dea0f290275a8f8242b2a6
 (DIR) parent 947dd058da448167406fb3904a78459d825f19b8
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Tue, 28 Jan 2014 17:19:56 +0100
       
       Terminal image viewer
       
       Diffstat:
         A imgt                                |      31 +++++++++++++++++++++++++++++++
       
       1 file changed, 31 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/imgt b/imgt
       t@@ -0,0 +1,31 @@
       +#!/bin/bash
       +#
       +# z3bra -- 2014-01-21
       +
       +test -z "$1" && exit
       +
       +W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay"
       +FILENAME=$1
       +FONTH=14 # Size of one terminal row
       +FONTW=8  # Size of one terminal column
       +COLUMNS=`tput cols`
       +LINES=`tput lines`
       +
       +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;0;0;$width;$height;;;;;$FILENAME\n4;\n3;"
       +
       +tput cup $(($height/$FONTH)) 0
       +echo -e $w3m_command|$W3MIMGDISPLAY