]> git.scottworley.com Git - picsort/blame - pics-preprocess
Stop if running low on disk space
[picsort] / pics-preprocess
CommitLineData
967baf16 1#!/usr/bin/env bash
e18c13a6 2
cd368e97
SW
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.
e18c13a6 6
95201e91
SW
7MINFREESPACE=$((10 * 1024 * 1024)) # 10GiB in KiB
8
9952a1a7 9SMALLHEIGHT=700
e18c13a6 10
47aee54b 11renice -n 19 $$
e18c13a6
SW
12
13for f;do
95201e91
SW
14 if (( "$(df -k . | awk 'NR == 2 { print $4 }')" < $MINFREESPACE ));then
15 echo "Out of disk space"
16 break
17 fi
cd368e97
SW
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"
1365c024
SW
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
7e0b085a 27 pics-run-ufraw "$exposure" "$f" "$out"
cd368e97 28 fi
1365c024
SW
29 if [[ -s "sm/$out" ]];then
30 echo "Skipping sm/$out"
31 else
cd368e97
SW
32 convert "$out" -geometry "x$SMALLHEIGHT" "sm/$out"
33 fi
34 done
35 else
1365c024
SW
36 if [[ -s "sm/$f" ]];then
37 echo "Skipping sm/$f"
38 else
bb17aed5 39 mkdir -p sm
cd368e97 40 convert "$f" -geometry "x$SMALLHEIGHT" "sm/$f"
fd69f569 41 fi
cd368e97 42 fi
e18c13a6 43done