indent2graph supports Graph::Easy format and strict tree-like input; td-gnuplot pass...
[hband-tools.git] / half-baked / embed-thumbnail
blob52ce0bcfb21e08cd0d3de8c144b9f9db5e8555de
1 #!/bin/bash
3 set -e
4 set -o pipefail
5 set -u
7 . /usr/lib/tool/bash-utils
9 for mediafile in "$@"
11 pathbasename=${mediafile%.*}
12 ext=${mediafile##*.}
13 mediafile_new=${pathbasename}-embedtn.$ext
14 tn_found=''
16 for tn_ext in webp png jpg
18 tn_path=$pathbasename.$tn_ext
19 if [ -s "$tn_path" ]
20 then
21 tn_path_new=$pathbasename.png
23 case $tn_ext in
24 webp)
25 dwebp "$tn_path" -o "$tn_path_new"
27 jpg)
28 convert "$tn_path" "$tn_path_new"
30 png)
31 true;;
33 false;;
34 esac
36 AtomicParsley "$mediafile" --artwork "$tn_path_new" -o "$mediafile_new"
37 mv "$mediafile_new" "$mediafile"
38 [ ! -e "$tn_path_new" ] || rm "$tn_path_new"
39 [ ! -e "$tn_path" ] || rm "$tn_path"
41 tn_found=1
42 break
44 done
46 if [ ! $tn_found ]
47 then
48 warnx "thumbnail not found for $mediafile"
50 done