mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-26 09:18:31 -05:00
50 lines
782 B
Bash
Executable File
50 lines
782 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Stolen from vifm/vifm#419
|
|
|
|
if [ "$#" -ne 3 ]
|
|
then
|
|
echo "Usage: $0 filename width height"
|
|
exit 1
|
|
fi
|
|
|
|
pw=$(($2*8))
|
|
ph=$(($3*21))
|
|
|
|
w=$(exiftool -m -p '$ImageWidth' "$1")
|
|
h=$(exiftool -m -p '$ImageHeight' "$1")
|
|
|
|
height=auto
|
|
width=auto
|
|
if [ $pw -lt $w ] && [ $ph -lt $h ]
|
|
then
|
|
newh=$(echo "($h*$pw)/$w" | bc)
|
|
# neww=$(echo "($w*$ph)/$h" | bc)
|
|
|
|
if [ $newh -le $ph ]; then
|
|
width=$pw
|
|
else
|
|
height=$ph
|
|
fi
|
|
elif [ $pw -lt $w ]
|
|
then
|
|
width=$pw
|
|
elif [ $ph -lt $h ]
|
|
then
|
|
height=$ph
|
|
fi
|
|
|
|
# debugging stuff
|
|
# echo pw=$pw ph=$ph
|
|
# echo w=$w h=$h
|
|
# echo neww=$neww newh=$newh
|
|
# exec echo width=$width height=$height
|
|
|
|
# account for GNU screen
|
|
if [ -n "$STY" ]
|
|
then
|
|
popt=-P
|
|
fi
|
|
|
|
exec img2sixel $popt --width=$width --height=$height "$1"
|