-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmk-thumbs.sh
More file actions
executable file
·62 lines (47 loc) · 1.82 KB
/
mk-thumbs.sh
File metadata and controls
executable file
·62 lines (47 loc) · 1.82 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
# mk-thumbs.sh
# 2005-05-15 PixEye@bigfoot.com Creation
nbps=1 # Number of wanted parameters (without options)
geometry="160x120" # Maximum thumbnail size
tool="convert" # Requires this tool as sub-program
thumbdir=".thumbnails" # Thumbnails directory
cmd=`basename $0` # Command name
usage="Usage: $cmd -h" # Help message:
usage=$usage"\n\tDisplay this help message.\n"
usage=$usage"\nUsage: $cmd [-n] [-g <geometry>] <pictures> [...]"
usage=$usage"\n\tMakes thumbnails from current directory pictures."
usage=$usage"\n\tThis script requires $tool (from the ImageMagick package)."
usage=$usage"\n\tThe default geometry for thumbnails is $geometry.\n"
usage=$usage"\n\tThe -n option avoid already existing thumb overwriting."
if test `uname` != "HP-UX" ; then e="-e" ; fi
if [ "$#" -ge 1 -a "$1" = "-n" ] ; then optn=true ; shift ; else optn=false ; fi
if [ "$#" -ge 2 -a "$1" = "-g" ] ; then geometry="$2" ; shift 2 ; fi
if [ "$#" -lt $nbps -o "$1" = "-h" ] # Check parameters number
then echo $e $usage ; exit 2 # Display help message and exit
fi
ltool=`type -p $tool|grep -v "no $tool in "` # Long name of the tool
if test -z "$ltool"
then echo $e "$cmd: This script requires $tool." ; exit 1
fi
while [ "$#" -ge 1 ] # Better than a "for" (case of filenames with spaces)
do
file="$1"
if test ! -r "$file"
then echo "$cmd: $file not readable!" 1>&2 ; shift ; continue
fi
if test -d "$file"
then echo "$cmd: $file is a directory!" 1>&2 ; shift ; continue
fi
mkdir -p `dirname "$file"`"/$thumbdir"
thumb=`dirname "$file"`"/$thumbdir/"`basename "$file"`
echo $e "$file ... \c"
if test -r "$thumb" && "$optn"
then echo "already existing." ; shift ; continue
fi
"$ltool" -geometry "$geometry" -interlace Plane "$file" "$thumb" \
&& echo OK
shift
done
exit 0
# Prefs for vim editing:
# vim: ts=8 sw=8 tw=80 noet