#!/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