]> git.scottworley.com Git - picsort/blame_incremental - pics-preprocess
Stop if running low on disk space
[picsort] / pics-preprocess
... / ...
CommitLineData
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
7MINFREESPACE=$((10 * 1024 * 1024)) # 10GiB in KiB
8
9SMALLHEIGHT=700
10
11renice -n 19 $$
12
13for 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
43done