diff options
| author | Marc Vertes <mvertes@free.fr> | 2020-11-01 09:32:20 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2020-11-01 09:32:20 +0100 |
| commit | 3bb7e9d0b1d7bc406bd2361f7484d4484eb483b1 (patch) | |
| tree | 9735fd2e0a2bf83cec9068b453fb9bdf2e7e2378 /bin/icat | |
| parent | aa1f45e33a957098615eca24d0b1b26c03b0eb57 (diff) | |
update
Diffstat (limited to 'bin/icat')
| -rwxr-xr-x | bin/icat | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -1,2 +1,28 @@ -#!/bin/sh -exec convert -resize '800x480>' -flatten -- ${1:--} sixel:- +#!/bin/sh -e +# Display images directly in terminal. +# Tested with xterm v361 + +# maxsize prints the geomtry size of terminal window, with +# a maximum value of 1000 pixels for width and height, or +# 640x480 if size can not be probed. +maxsize() { + [ "$WINDOWID" ] || { echo "640x480>"; return; } + xwininfo -id "$WINDOWID" | { + w=1000 h=1000 + while read -r a b; do + case $a in + (Width:) [ $((b < w)) = 1 ] && w=$b ;; + (Height:) [ $((b < h)) = 1 ] && h=$b ;; + esac + done + echo "${w}x$h" + } +} + +# Use convert(1) from imagemagick to output sixel format. +# -flatten uses the terminal background color as transparent layer +# -resize use the terminal size as bounding box, with a limit of 1000 pixels +# image is not resized if smaller than limit +#exec convert -resize "$(maxsize)>" -transparent-color white -flatten -- ${1:--} sixel:- +# color #rrrrggggbbbb +exec convert -resize "$(maxsize)>" -- ${1:--} sixel:${2:--} |
