ajout du script utilisé pour...
|
1 |
#!/bin/bash |
2 | ||
3 |
thumbnailsconf=${1:-${0##*/}.conf} |
|
4 |
test -r "$thumbnailsconf" || exit 1 |
|
modifie stockage des infos s...
|
5 |
shift |
ajout du script utilisé pour...
|
6 | |
modifie stockage des infos s...
|
7 |
declare -A imgsize width height |
ajout du script utilisé pour...
|
8 | |
modifie stockage des infos s...
|
9 |
imgsize[xxlarge]="1656 1242" |
10 |
imgsize[xlarge]=" 1224 918" |
|
11 |
imgsize[large]=" 1008 756" |
|
12 |
imgsize[medium]=" 792 594" |
|
13 |
imgsize[small]=" 576 432" |
|
14 |
imgsize[xsmall]=" 432 324" |
|
15 |
imgsize[2small]=" 240 180" |
|
16 | ||
17 |
if test $# -gt 0; then |
|
18 |
filter=$(echo $@ | sed 's/ /|/g') |
|
19 |
for size in ${!imgsize[@]}; do |
|
20 |
if ! [[ $size =~ ^(${filter})$ ]]; then |
|
21 |
unset imgsize[$size] |
|
22 |
else |
|
23 |
geometry=(${imgsize[$size]}) |
|
24 |
width[$size]=${geometry[0]} |
|
25 |
height[$size]=${geometry[1]} |
|
26 |
fi |
|
27 |
done |
|
28 |
fi |
|
29 | ||
30 |
for size in ${!imgsize[@]}; do |
|
31 |
geometry=(${imgsize[$size]}) |
|
32 |
width[$size]=${geometry[0]} |
|
33 |
height[$size]=${geometry[1]} |
|
34 |
done |
|
ajout du script utilisé pour...
|
35 | |
ajout de tests
|
36 |
if which readconf > /dev/null; then |
plus besoin de galeries nomm...
|
37 |
eval $(readconf --conf "$thumbnailsconf" --section=mysql --section=path --case-sensitive) |
ajout de tests
|
38 |
else |
39 |
echo readconf needed ! |
|
40 |
echo PATH = $PATH |
|
modification de l'URL du dép...
|
41 |
echo get readconf at https://seb.lautre.net/git/seb/scripts/raw/master/readconf |
ajout de tests
|
42 |
exit 1 |
43 |
fi |
|
44 | ||
45 |
if ! which convert > /dev/null; then |
|
46 |
echo please install ImageMagick |
|
47 |
exit 1 |
|
48 |
fi |
|
ajout du script utilisé pour...
|
49 | |
ajoute 3 options: IMPORT, FO...
|
50 |
sqlcmd="select path from ${dbprefix}images |
51 |
where id in ( |
|
52 |
select distinct image_id from ${dbprefix}image_category |
|
53 |
where category_id in ( |
|
54 |
select id from ${dbprefix}categories where dir is ${IMPORT:+not} NULL |
|
55 |
) |
|
plus besoin de galeries nomm...
|
56 |
)" |
ajout du script utilisé pour...
|
57 | |
multiples améliorations
|
58 |
IFS=$'\n' |
59 |
for file in $(mysql -N -u $dbuser -p${dbpasswd} $dbname <<< $sqlcmd); do |
|
plus besoin de galeries nomm...
|
60 |
format="" |
61 |
fnNoExt="${file%.*}" |
|
62 |
fnExt="${file##*.}" |
|
63 |
fnPath="${file%/*}" |
|
multiples améliorations
|
64 |
test $fnExt = 'mp4' && continue |
65 |
cmd="sudo -u www-data convert \"$site/$file\" -write mpr:image +delete " |
|
66 |
count=0 |
|
modifie stockage des infos s...
|
67 |
for size in ${!imgsize[@]}; do |
ajoute 3 options: IMPORT, FO...
|
68 |
if ! test -e "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" -a -z "$FORCE"; then |
modifie stockage des infos s...
|
69 |
format+="$size " |
multiples améliorations
|
70 |
cmd+="mpr:image -filter Lanczos -auto-orient -strip -quality 95 -interlace line -sampling-factor 4:2:2 " |
modifie stockage des infos s...
|
71 |
cmd+="-resize ${width[$size]}x${height[$size]} -write \"${destDir}/${fnNoExt}-${size:0:2}.$fnExt\" +delete " |
multiples améliorations
|
72 |
let count++ |
ajout du script utilisé pour...
|
73 |
fi |
74 |
done |
|
plus besoin de galeries nomm...
|
75 |
if test -n "$format"; then |
76 |
echo "$site/$file : $format" |
|
ajoute 3 options: IMPORT, FO...
|
77 |
if test -n "$LIST"; then |
78 |
continue |
|
79 |
fi |
|
plus besoin de galeries nomm...
|
80 |
echo -n "please wait... " |
multiples améliorations
|
81 |
cmd=$(sed -r 's/^(.+) -write (.*) \+delete $/\1 \2/' <<< $cmd) |
82 |
eval $(echo -e nice -20 $cmd) |
|
modifie stockage des infos s...
|
83 |
for size in ${!imgsize[@]}; do |
84 |
test -s "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" || echo "missing extension ${size:0:2}.$fnExt" |
|
multiples améliorations
|
85 |
done |
86 |
echo "done, sleeping..." |
|
87 |
sleep $(( 2 + $count )) |
|
plus besoin de galeries nomm...
|
88 |
fi |
ajout du script utilisé pour...
|
89 |
done |