diff options
Diffstat (limited to '')
| -rwxr-xr-x | bin/mktoes | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/mktoes b/bin/mktoes new file mode 100755 index 0000000..7eb47cf --- /dev/null +++ b/bin/mktoes @@ -0,0 +1,27 @@ +#!/bin/sh +set -eu +target=${1:?target} +size=${2:-normal} + +case $size in +normal) px=128 ;; +large) px=256 ;; +x-large) px=512 ;; +xx-large) px=1024 ;; +*) exit 1 ;; +esac + +md5=$(echo "file://$(readlink -e "$target")" | md5sum | cut -d' ' -f1) +dir=${XDG_CACHE_HOME:-$HOME/.cache}/thumbnails/$size +path=$dir/$md5.png +printf '%s' $path +[ -n "${MKTOES_NOGEN:-}" ] && exit 0 + +test -f $path && exit 0 +mkdir -p $dir +chmod 700 $dir + +tmp=$dir/.$$.$md5.png +ffmpeg -hide_banner -i "$target" -vf scale=$px:$px:force_original_aspect_ratio=decrease $tmp 2>/dev/null +mv -f $tmp $path +chmod 600 $path |