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