]> git.scottworley.com Git - picsort/blob - pics-preprocess
Key creation
[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 ionice -c 3 -p $$
13
14 for f;do
15 if (( "$(df -k . | awk 'NR == 2 { print $4 }')" < $MINFREESPACE ));then
16 echo "Out of disk space"
17 break
18 fi
19 if [[ "$f" == *.NEF ]];then
20 for level in {10..30};do
21 mkdir -p {,sm/}"$level"
22 base="$(basename "$f")"
23 out="$level/${base%.NEF}.jpeg"
24 if [[ -s "$out" ]];then
25 echo "Skipping $out"
26 else
27 exposure=$(dc <<< "2k $level 4 / 3.5-p") # 10 to 30 -> -1 to 4 in .25 steps
28 pics-run-ufraw "$exposure" "$f" "$out"
29 fi
30 if [[ -s "sm/$out" ]];then
31 echo "Skipping sm/$out"
32 else
33 convert "$out" -geometry "x$SMALLHEIGHT" "sm/$out"
34 fi
35 done
36 else
37 if [[ -s "sm/$f" ]];then
38 echo "Skipping sm/$f"
39 else
40 mkdir -p sm
41 convert "$f" -geometry "x$SMALLHEIGHT" "sm/$f"
42 fi
43 fi
44 done