]> git.plutz.net Git - serve0/blob - multitag.sh
further increase thumbnail quality (though still using jpeg ;-)
[serve0] / multitag.sh
1 #!/bin/sh
2
3 . "$_EXEC/cgilite/storage.sh"
4 . "$_EXEC/indexmeta.sh"
5
6 for select in $(seq 1 $(POST_COUNT select)); do
7   file="$_DATA/$ITEM/$(POST select $select)"
8   meta="${file%/*}/.index/meta"
9
10   fn="$(meta_name "$file")"
11   read -r length width height tags comment discard <<-EOF
12         $(meta_info "$file")
13         EOF
14   [ "${length%%[1-9]*}" -o "${width%%[1-9]*}" -o "${height%%[1-9]*}" = 0 ] \
15   && read -r length width height discard <<-EOF
16         $(meta_line "$file"; echo Rereading meta for "$file" >&2)
17         EOF
18   [ "${tags%%tags=*}" ] && tags='tags=';
19   [ "${comment%%comment=*}" ] && comment='comment='
20
21   if LOCK "$meta"; then
22     grep -avF " $fn" "$meta" >"${meta}.tmp"
23
24     tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
25
26     for tn in $(seq 1 $(POST_COUNT tag)); do
27       tags="$(printf '%s\n%s' "$tags" "$(POST tag $tn)")"
28     done
29     tags="$(printf '%s\n%s' "$tags" "$(POST newtag |tr -d '\r')")"
30
31     tags="$(printf %s "$tags" |sort -u |tr '\n' ,)"
32     printf '%i\t%i\t%i\ttags=%s\t%s\t%s\n' \
33            "$length" "$width" "$height" \
34            "$(STRING "${tags#,}")" \
35            "$comment" "$fn" \
36     >>"${meta}.tmp"
37     mv "${meta}.tmp" "$meta"
38
39     RELEASE "$meta"
40   fi
41 done