scripts / thumbnails /
Newer Older
59 lines | 2.077kb
ajout du script utilisé pour...
Sébastien MARQUE authored on 2016-11-19
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

            
22
eval $(readconf --conf "$thumbnailsconf" -s mysql -s galeries -s path --case-sensitive --array=galerie)
23

            
24
for ((g=0; g<${#galerie[@]}; g++)); do
25
    sqlcmd="select concat('file=', path, ';rotation=', rotation * 90) from piwigo_images \
26
               where id in ( \
27
                  select image_id from piwigo_image_category \
28
                      where category_id in ( \
29
                          select id from piwigo_categories where name = '${galerie[$g]}' \
30
                      ) \
31
               )"
32

            
33
    for image in $(mysql -N -u $dbuser -p${dbpasswd} $dbname <<< $sqlcmd); do
34
        eval "$image"
35
        format=""
36
        fnNoExt="${file%.*}"
37
        fnExt="${file##*.}"
38
        fnPath="${file%/*}"
correction de chemins
Sébastien MARQUE authored on 2017-02-12
39
        mkdir -p $destDir/$fnPath
ajout du script utilisé pour...
Sébastien MARQUE authored on 2016-11-19
40
        cmd="nice -n20 convert $site/$file -write mpr:image +delete "
41
        for ((i=0; i<${#imgsize[@]}; i+=3)); do
correction de chemins
Sébastien MARQUE authored on 2017-02-12
42
            if ! test -e ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt; then
ajout du script utilisé pour...
Sébastien MARQUE authored on 2016-11-19
43
                format+="${imgsize[i]} "
44
                cmd+="mpr:image -filter Lanczos -strip -quality 95 -interlace line -sampling-factor 4:2:2 "
45
                if test $rotation -ne 0; then
46
                    cmd+="-rotate -$rotation -orient top-left "
47
                fi
correction de chemins
Sébastien MARQUE authored on 2017-02-12
48
                cmd+="-resize ${imgsize[i+1]}x${imgsize[i+2]} -write ${destDir}/${fnNoExt}-${imgsize[i]:0:2}.$fnExt +delete "
ajout du script utilisé pour...
Sébastien MARQUE authored on 2016-11-19
49
            fi
50
        done
51
        cmd=$(sed 's/\s*+delete\s*$//' <<< $cmd)
52
        if test -n "$format"; then
53
            echo "$site/$file : $format"
54
            eval "$(echo -e $cmd)"
correction de chemins
Sébastien MARQUE authored on 2017-02-12
55
            echo done
ajout du script utilisé pour...
Sébastien MARQUE authored on 2016-11-19
56
            sleep 30
57
        fi
58
    done
59
done