]> git.scottworley.com Git - picsort/blob - pics-preprocess
ec66abfb9bd3550838be67276c99d793649a8ce1
[picsort] / pics-preprocess
1 #!/usr/bin/env bash
2
3 # Pass .NEF and .jpeg files as $@.
4 # This makes many variants of each .NEF file at different exposure levels
5 # and makes reduced-size versions for faster browsing.
6
7 MINFREESPACE=$((10 * 1024 * 1024)) # 10GiB in KiB
8
9 SMALLHEIGHT=700
10
11 renice -n 19 $$
12
13 for f;do
14 if (( "$(df -k . | awk 'NR == 2 { print $4 }')" < $MINFREESPACE ));then
15 echo "Out of disk space"
16 break
17 fi
18 if [[ "$f" == *.NEF ]];then
19 for level in {10..30};do
20 mkdir -p {,sm/}"$level"
21 base="$(basename "$f")"
22 out="$level/${base%.NEF}.jpeg"
23 if [[ -s "$out" ]];then
24 echo "Skipping $out"
25 else
26 exposure=$(dc <<< "2k $level 4 / 3.5-p") # 10 to 30 -> -1 to 4 in .25 steps
27 pics-run-ufraw "$exposure" "$f" "$out"
28 fi
29 if [[ -s "sm/$out" ]];then
30 echo "Skipping sm/$out"
31 else
32 convert "$out" -geometry "x$SMALLHEIGHT" "sm/$out"
33 fi
34 done
35 else
36 if [[ -s "sm/$f" ]];then
37 echo "Skipping sm/$f"
38 else
39 mkdir -p sm
40 convert "$f" -geometry "x$SMALLHEIGHT" "sm/$f"
41 fi
42 fi
43 done