4 thumbs="$HOME/.fvwm/.thumbs"
6 if [ ! -d "$thumbs" ]; then
7 mkdir "$thumbs" || exit 1
14 while [ "${1#--}" != "$1" -a "$1" != "-" ]; do
15 if [ "$1" = "--small" ]; then
17 elif [ "$1" = "--size" ]; then
20 elif [ "$1" = "--music" ]; then
22 elif [ "$1" = "--image" ]; then
25 echo "unrecognised option: $1" 1>&2
30 [ "$1" = "-" ] && shift
32 if ! expr match "$size" '^\([0-9]*\(x[0-9]\+\)\?\)$' >/dev/null 2>&1; then
33 echo "invalid size specification: $size" 1>&2
38 echo "usage: thumbnail.sh [--small|--size <spec>] [--image] [--music] path" 1>&2
42 if [ -n "$ismusic" ]; then
43 path="$music/`dirname "${1#$music}"`/cover.jpg"
44 [ ! -f "$path" ] && path="${path%jpg}png"
49 [ ! -f "$path" ] && exit 0
51 image="`readlink -f -- "$path"`"
52 [ ! -f "$image" ] && exit 0
54 thumb="$thumbs/`echo -n $image | md5sum - | cut -d ' ' -f 1`_$size.png"
55 if [ -f "$thumb" ]; then
56 mtime_s="`stat -c %Y -- "$image"`"
57 mtime_t="`stat -c %Y -- "$thumb"`"
58 if [ "$mtime_s" -gt "$mtime_t" ]; then
59 convert -scale "$size" "$image" "$thumb"
62 convert -scale "$size" "$image" "$thumb"
66 [ -n "$printimg" ] && echo "$image"