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 |
23 |
eval $(readconf --conf "$thumbnailsconf" -s mysql -s galeries -s path --case-sensitive --array=galerie) |
|
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 | |
36 |
for ((g=0; g<${#galerie[@]}; g++)); do |
|
préfixe de table variable
|
37 |
sqlcmd="select concat('file=', path, ';rotation=', rotation * 90) from ${dbprefix}images \ |
ajout du script utilisé pour...
|
38 |
where id in ( \ |
préfixe de table variable
|
39 |
select image_id from ${dbprefix}image_category \ |
ajout du script utilisé pour...
|
40 |
where category_id in ( \ |
préfixe de table variable
|
41 |
select id from ${dbprefix}categories where name = '${galerie[$g]}' \ |
ajout du script utilisé pour...
|
42 |
) \ |
43 |
)" |
|
44 | ||
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%/*}" |
|
correction de chemins
|
51 |
mkdir -p $destDir/$fnPath |
ajout du script utilisé pour...
|
52 |
cmd="nice -n20 convert $site/$file -write mpr:image +delete " |
53 |
for ((i=0; i<${#imgsize[@]}; i+=3)); do |
|
correction de chemins
|
54 |
if ! test -e ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt; then |
ajout du script utilisé pour...
|
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 |
|
correction de chemins
|
60 |
cmd+="-resize ${imgsize[i+1]}x${imgsize[i+2]} -write ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt +delete " |
ajout du script utilisé pour...
|
61 |
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)" |
|
correction de chemins
|
67 |
echo done |
ajout du script utilisé pour...
|
68 |
sleep 30 |
69 |
fi |
|
70 |
done |
|
71 |
done |