-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkthumbs
executable file
·53 lines (48 loc) · 1.5 KB
/
mkthumbs
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
#!/bin/sh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2014 Jeremy Brubaker <jbru362@gmail.com>
#
# abstract: create image thumbnails
#
# USAGE : mkthumbs [dir] [scalefac]
#
# INPUTS : [dir] -> the directory with jpg files
# [scalefac] -> the factor to scale them down by
#
# OUTPUTS: scaled down .thumb.jpg files of same basename
#
# EXAMPLE: to scale down your cwd .jpg's by a factor of 8:
# % ./mkthumbs . 8
#
# $Id: mkthumbs,v 1.0 2001.01.28 14:50:59 tkralidi Exp $
if [ $# -ne 2 ]; then
echo "Usage: $0 [dir] [scalefac]"
exit 1
fi
DJPEG=`which djpeg`
CJPEG=`which cjpeg`
echo "Working on .jpg files in $1"
for i in "$1"/*.jpg; do
if [ -f "$i" ]; then
printf "Scaling %s by %s..." "$i" "$2"
djpeg -scale "1/$2" "$i" | cjpeg > "$1/th.$i"
printf "th.%s created\n" "$i"
else
echo "No files in $1 of type .jpg"
echo "Exiting"
exit 2
fi
done