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 | ||
ajout de tests
|
20 |
if which readconf > /dev/null; then |
plus besoin de galeries nomm...
|
21 |
eval $(readconf --conf "$thumbnailsconf" --section=mysql --section=path --case-sensitive) |
ajout de tests
|
22 |
else |
23 |
echo readconf needed ! |
|
24 |
echo PATH = $PATH |
|
modification de l'URL du dép...
|
25 |
echo get readconf at https://seb.lautre.net/git/seb/scripts/raw/master/readconf |
ajout de tests
|
26 |
exit 1 |
27 |
fi |
|
28 | ||
29 |
if ! which convert > /dev/null; then |
|
30 |
echo please install ImageMagick |
|
31 |
exit 1 |
|
32 |
fi |
|
ajout du script utilisé pour...
|
33 | |
multiples améliorations
|
34 |
sqlcmd="select path from ${dbprefix}images \ |
plus besoin de galeries nomm...
|
35 |
where id in ( \ |
plusieurs albums pour une mê...
|
36 |
select distinct image_id from ${dbprefix}image_category \ |
plus besoin de galeries nomm...
|
37 |
where category_id in ( \ |
38 |
select id from ${dbprefix}categories where dir is NULL \ |
|
39 |
) \ |
|
40 |
)" |
|
ajout du script utilisé pour...
|
41 | |
multiples améliorations
|
42 |
IFS=$'\n' |
43 |
for file in $(mysql -N -u $dbuser -p${dbpasswd} $dbname <<< $sqlcmd); do |
|
plus besoin de galeries nomm...
|
44 |
format="" |
45 |
fnNoExt="${file%.*}" |
|
46 |
fnExt="${file##*.}" |
|
47 |
fnPath="${file%/*}" |
|
multiples améliorations
|
48 |
test $fnExt = 'mp4' && continue |
49 |
cmd="sudo -u www-data convert \"$site/$file\" -write mpr:image +delete " |
|
50 |
count=0 |
|
plus besoin de galeries nomm...
|
51 |
for ((i=0; i<${#imgsize[@]}; i+=3)); do |
multiples améliorations
|
52 |
if ! test -e "${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt"; then |
plus besoin de galeries nomm...
|
53 |
format+="${imgsize[i]} " |
multiples améliorations
|
54 |
cmd+="mpr:image -filter Lanczos -auto-orient -strip -quality 95 -interlace line -sampling-factor 4:2:2 " |
55 |
cmd+="-resize ${imgsize[i+1]}x${imgsize[i+2]} -write \"${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt\" +delete " |
|
56 |
let count++ |
|
ajout du script utilisé pour...
|
57 |
fi |
58 |
done |
|
plus besoin de galeries nomm...
|
59 |
if test -n "$format"; then |
60 |
echo "$site/$file : $format" |
|
61 |
echo -n "please wait... " |
|
multiples améliorations
|
62 |
cmd=$(sed -r 's/^(.+) -write (.*) \+delete $/\1 \2/' <<< $cmd) |
63 |
eval $(echo -e nice -20 $cmd) |
|
64 |
for ((i=0; i<${#imgsize[@]}; i+=3)); do |
|
65 |
test -s "${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt" || echo "missing extension ${imgsize[i]:0:2}.$fnExt" |
|
66 |
done |
|
67 |
echo "done, sleeping..." |
|
68 |
sleep $(( 2 + $count )) |
|
plus besoin de galeries nomm...
|
69 |
fi |
ajout du script utilisé pour...
|
70 |
done |