plus besoin de galeries nommées, et plus de message...
...d'erreur pour convert
... | ... |
@@ -20,7 +20,7 @@ set_imgsize '2small' 144 144 |
20 | 20 |
set_imgsize 'thumb' 120 120 |
21 | 21 |
|
22 | 22 |
if which readconf > /dev/null; then |
23 |
- eval $(readconf --conf "$thumbnailsconf" -s mysql -s galeries -s path --case-sensitive --array=galerie) |
|
23 |
+ eval $(readconf --conf "$thumbnailsconf" --section=mysql --section=path --case-sensitive) |
|
24 | 24 |
else |
25 | 25 |
echo readconf needed ! |
26 | 26 |
echo PATH = $PATH |
... | ... |
@@ -33,39 +33,46 @@ if ! which convert > /dev/null; then |
33 | 33 |
exit 1 |
34 | 34 |
fi |
35 | 35 |
|
36 |
-for ((g=0; g<${#galerie[@]}; g++)); do |
|
37 |
- sqlcmd="select concat('file=', path, ';rotation=', rotation * 90) from ${dbprefix}images \ |
|
38 |
- where id in ( \ |
|
39 |
- select image_id from ${dbprefix}image_category \ |
|
40 |
- where category_id in ( \ |
|
41 |
- select id from ${dbprefix}categories where name = '${galerie[$g]}' \ |
|
42 |
- ) \ |
|
43 |
- )" |
|
36 |
+sqlcmd="select path, rotation from ${dbprefix}images \ |
|
37 |
+ where id in ( \ |
|
38 |
+ select image_id from ${dbprefix}image_category \ |
|
39 |
+ where category_id in ( \ |
|
40 |
+ select id from ${dbprefix}categories where dir is NULL \ |
|
41 |
+ ) \ |
|
42 |
+ )" |
|
44 | 43 |
|
45 |
- for image in $(mysql -N -u $dbuser -p${dbpasswd} $dbname <<< $sqlcmd); do |
|
46 |
- eval "$image" |
|
47 |
- format="" |
|
48 |
- fnNoExt="${file%.*}" |
|
49 |
- fnExt="${file##*.}" |
|
50 |
- fnPath="${file%/*}" |
|
51 |
- mkdir -p $destDir/$fnPath |
|
52 |
- cmd="nice -n20 convert $site/$file -write mpr:image +delete " |
|
53 |
- for ((i=0; i<${#imgsize[@]}; i+=3)); do |
|
54 |
- if ! test -e ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt; then |
|
55 |
- format+="${imgsize[i]} " |
|
56 |
- cmd+="mpr:image -filter Lanczos -strip -quality 95 -interlace line -sampling-factor 4:2:2 " |
|
57 |
- if test $rotation -ne 0; then |
|
58 |
- cmd+="-rotate -$rotation -orient top-left " |
|
59 |
- fi |
|
60 |
- cmd+="-resize ${imgsize[i+1]}x${imgsize[i+2]} -write ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt +delete " |
|
44 |
+for image in $(mysql -N -u $dbuser -p${dbpasswd} $dbname <<< $sqlcmd | awk '{printf("file=%s;rotation=%s\n",$1,$2*90)}'); do |
|
45 |
+ eval "$image" |
|
46 |
+ format="" |
|
47 |
+ fnNoExt="${file%.*}" |
|
48 |
+ fnExt="${file##*.}" |
|
49 |
+ fnPath="${file%/*}" |
|
50 |
+ mkdir -p $destDir/$fnPath |
|
51 |
+ cmd="convert $site/$file -write mpr:image +delete " |
|
52 |
+ for ((i=0; i<${#imgsize[@]}; i+=3)); do |
|
53 |
+ if ! test -e ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt; then |
|
54 |
+ format+="${imgsize[i]} " |
|
55 |
+ cmd+="mpr:image -filter Lanczos -strip -quality 95 -interlace line -sampling-factor 4:2:2 " |
|
56 |
+ if test $rotation -ne 0; then |
|
57 |
+ cmd+="-rotate -$rotation -orient top-left " |
|
61 | 58 |
fi |
62 |
- done |
|
63 |
- cmd=$(sed 's/\s*+delete\s*$//' <<< $cmd) |
|
64 |
- if test -n "$format"; then |
|
65 |
- echo "$site/$file : $format" |
|
66 |
- eval "$(echo -e $cmd)" |
|
67 |
- echo done |
|
68 |
- sleep 30 |
|
59 |
+ cmd+="-resize ${imgsize[i+1]}x${imgsize[i+2]} -write ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt +delete " |
|
69 | 60 |
fi |
70 | 61 |
done |
62 |
+ cmd=$(awk '{for (i=1; i<=NF - 3; i++) printf("%s ", $i); printf("%s", $(NF-1))}' <<< $cmd) |
|
63 |
+ if test -n "$format"; then |
|
64 |
+ echo "$site/$file : $format" |
|
65 |
+ echo -n "please wait... " |
|
66 |
+ if test -z "$2"; then |
|
67 |
+ eval "$(echo -e sudo -u www-data nice -20 $cmd)" |
|
68 |
+ for ((i=0; i<${#imgsize[@]}; i+=3)); do |
|
69 |
+ test -s ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt || echo "missing extension ${imgsize[i]:0:2}.$fnExt" |
|
70 |
+ done |
|
71 |
+ echo "done, sleeping..." |
|
72 |
+ sleep 10 |
|
73 |
+ else |
|
74 |
+ echo $cmd |
|
75 |
+ echo |
|
76 |
+ fi |
|
77 |
+ fi |
|
71 | 78 |
done |