-
Notifications
You must be signed in to change notification settings - Fork 7
/
RAW_convert.sh
executable file
·88 lines (77 loc) · 1.85 KB
/
RAW_convert.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# Part of Macro-scripts package (a complete Open Source workflow for processing macro focus stacking photographs)
# Written by Sergey Mashchenko
# Bash script to convert raw images (CR2, DNG etc.) to 48-bit TIFF images.
# It can use either sRGB or linear color space, and can optionally accept custom white balance coefficients
# (computed by applying another script - WB.sh - to a raw photograph of a gray card).
# If dark.tiff present in the local folder, it will be subtracted from the image(s), before debayering.
if test $# -lt 1
then
echo
echo "Syntax:"
echo " RAW_convert.sh [-l] [-r <r g b g>] image1 [image2 image3 ...]"
echo
echo "-l: use linear color space"
echo "-r <r g b g>: use custom white balance coefficients r, g, b, g"
echo
exit
fi
# Processing optional switches
args=("$@")
arg_r=-1
arg_l=-1
for i in 0 1 5
do
if test "${args[$i]}" = "-l"
then
arg_l=$i
fi
if test "${args[$i]}" = "-r"
then
arg_r=$i
fi
done
if test $arg_l -ge 0
then
echo "Using linear color space"
OPT="-4"
else
echo "Using sRGB color space"
OPT="-6 -W"
fi
if test $arg_r -ge 0
then
echo "Using custom white balance"
OPT2="${args[$arg_r]} ${args[$(($arg_r+1))]} ${args[$(($arg_r+2))]} ${args[$(($arg_r+3))]} ${args[$(($arg_r+4))]}"
else
echo "Using system white balance"
OPT2=""
fi
if test $arg_l -ge 0
then
shift
fi
if test $arg_r -ge 0
then
shift 5
fi
# Copying the deadpixels.txt file if present:
if test -f ~/deadpixels.txt
then
\cp ~/deadpixels.txt .
dead_arg="-P deadpixels.txt"
else
dead_arg=""
fi
if test -f dark.tiff
then
magick convert dark.tiff dark.pgm
# Subtracting a dark image if present in the current directory:
OPT3="-K dark.pgm"
fi
echo "dcraw arguments: $dead_arg $OPT $OPT2 $OPT3"
# RAW images conversion to 48-bit TIFFs:
dcraw $dead_arg $OPT $OPT2 $OPT3 -T $*
echo
echo "Success!"
echo