... | ... |
@@ -1,5 +1,9 @@ |
1 | 1 |
#!/bin/bash |
2 | 2 |
|
3 |
+set -e |
|
4 |
+ |
|
5 |
+test $USER = www-data |
|
6 |
+ |
|
3 | 7 |
thumbnailsconf=${1:-${0##*/}.conf} |
4 | 8 |
test -r "$thumbnailsconf" || exit 1 |
5 | 9 |
shift |
... | ... |
@@ -13,6 +17,7 @@ imgsize[medium]=" 792 594" |
13 | 17 |
imgsize[small]=" 576 432" |
14 | 18 |
imgsize[xsmall]=" 432 324" |
15 | 19 |
imgsize[2small]=" 240 180" |
20 |
+imgsize[square]=" 120 120" |
|
16 | 21 |
|
17 | 22 |
if test $# -gt 0; then |
18 | 23 |
filter=$(echo $@ | sed 's/ /|/g') |
... | ... |
@@ -82,16 +87,19 @@ function calc_left () { |
82 | 87 |
} |
83 | 88 |
|
84 | 89 |
declare -A formats |
90 |
+total_ext=1 |
|
85 | 91 |
get_formats |
92 |
+let total_ext-- |
|
86 | 93 |
|
87 | 94 |
if test -n "$LIST"; then |
88 |
- for file in ${!formats[@]}; do |
|
95 |
+ for file in "${!formats[@]}"; do |
|
89 | 96 |
echo "[${#formats[@]}/$total_ext] $file : ${formats[$file]}" |
90 | 97 |
calc_left |
91 | 98 |
done |
92 | 99 |
else |
93 |
- for file in ${!formats[@]}; do |
|
94 |
- unset cmd sleep_duration |
|
100 |
+ for file in "${!formats[@]}"; do |
|
101 |
+ unset cmd |
|
102 |
+ sleep_duration=1 |
|
95 | 103 |
get_ext_fn "$file" |
96 | 104 |
for size in ${formats[$file]}; do |
97 | 105 |
cmd+=(mpr:image -resize ${width[$size]}x${height[$size]} -write "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" +delete) |
... | ... |
@@ -99,9 +107,9 @@ else |
99 | 107 |
done |
100 | 108 |
printf "\r\033[K[${#formats[@]}/$total_ext] $file : ${formats[$file]}" |
101 | 109 |
cmd[-1]="null:" |
102 |
- sudo -u www-data nice -20 convert \ |
|
110 |
+ nice -20 convert \ |
|
103 | 111 |
-filter Lanczos -strip -auto-orient -quality 95 -interlace line -sampling-factor 4:2:2 \ |
104 |
- "$site/$file" +write ${cmd[@]} |
|
112 |
+ "$site/$file" +write "${cmd[@]}" |
|
105 | 113 |
for size in ${!imgsize[@]}; do |
106 | 114 |
test -s "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" || echo -e "\nmissing extension ${size:0:2}.$fnExt" |
107 | 115 |
done |