ajout du script utilisé pour...
|
1 |
#!/bin/bash |
2 | ||
3 |
thumbnailsconf=${1:-${0##*/}.conf} |
|
4 |
test -r "$thumbnailsconf" || exit 1 |
|
5 | ||
6 |
function set_imgsize () { |
|
7 |
imgsize[${#imgsize[@]}]=$1 |
|
8 |
imgsize[${#imgsize[@]}]=$2 |
|
9 |
imgsize[${#imgsize[@]}]=$3 |
|
10 |
} |
|
11 | ||
12 |
#set_imgsize 'custom' 1656 1242 |
|
13 |
set_imgsize 'xxlarge' 1224 918 |
|
14 |
set_imgsize 'xlarge' 1008 756 |
|
15 |
set_imgsize 'large' 792 594 |
|
16 |
set_imgsize 'medium' 576 432 |
|
17 |
set_imgsize 'small' 432 324 |
|
18 |
set_imgsize 'xsmall' 240 240 |
|
19 |
set_imgsize '2small' 144 144 |
|
20 |
set_imgsize 'thumb' 120 120 |
|
21 | ||
ajout de tests
|
22 |
if which readconf > /dev/null; then |
plus besoin de galeries nomm...
|
23 |
eval $(readconf --conf "$thumbnailsconf" --section=mysql --section=path --case-sensitive) |
ajout de tests
|
24 |
else |
25 |
echo readconf needed ! |
|
26 |
echo PATH = $PATH |
|
27 |
echo get readconf at https://sebmarque.hd.free.fr/git/seb/scripts/raw/master/readconf |
|
28 |
exit 1 |
|
29 |
fi |
|
30 | ||
31 |
if ! which convert > /dev/null; then |
|
32 |
echo please install ImageMagick |
|
33 |
exit 1 |
|
34 |
fi |
|
ajout du script utilisé pour...
|
35 | |
plus besoin de galeries nomm...
|
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 |
)" |
|
ajout du script utilisé pour...
|
43 | |
plus besoin de galeries nomm...
|
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 " |
|
ajout du script utilisé pour...
|
58 |
fi |
plus besoin de galeries nomm...
|
59 |
cmd+="-resize ${imgsize[i+1]}x${imgsize[i+2]} -write ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt +delete " |
ajout du script utilisé pour...
|
60 |
fi |
61 |
done |
|
plus besoin de galeries nomm...
|
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 |
|
ajout du script utilisé pour...
|
78 |
done |