blob: 3c1a633d511bac55eb78dea4b7695a429aa15ff4 (
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
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
|
#!/bin/sh -ex
_img_dirs="$( find . -maxdepth 1 -type d | sed -e '1d' -e 's/^\.\///' )"
_thumb_size="835x"
_thumbs_dir="thumbs"
_force_render=0
usage() {
echo "usage: $0 [-f|--force]"
}
[ -n "$1" ] && \
case $1 in
-f|--force)
_force_render=1
;;
-h|--help)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
for dir in $_img_dirs
do
cd "./$dir" || exit 1
mkdir -p "$_thumbs_dir"
_imgs="$(find . -maxdepth 1 \
-iname "*.jpg" -or \
-iname "*.jpeg" -or \
-iname "*.gif" -or \
-iname "*.png" -type f | cut -b 3-)"
for _img in $_imgs
do
_ext="${_img##*.}"
_name="${_img%%.*}"
_thumb="./$_thumbs_dir/${_name}_thumb.${_ext}"
[ "$_force_render" -eq 1 ] || [ ! -f "$_thumb" ] && \
{
# when compressed, gifs look ugly, so just copy them
# i know this is bad, but i'll adress it later
[ "$_ext" = "gif" ] && \
echo "copied $1 to $_thumb" && \
cp "$_img" "$_thumb" && continue
echo "creating thumbnail for $_name..."
convert "$_img" -resize "$_thumb_size" "$_thumb"
}
done
cd ".."
done
|