blob: 7eb47cfcc9af52ad7df9192549e0c627588a13b0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|