-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtakepicture
executable file
·134 lines (108 loc) · 2.99 KB
/
takepicture
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
#
# Licensing:
#
# Copyright © Laurence Lumi 2017
# Licensed GNU General Public License v3
# which can be found here https://www.gnu.org/licenses/gpl-3.0.en.html
#
progname=`basename $0`
usage()
{
echo >&2 ""
echo >&2 "$progname:" "$@"
cat << MESSAGE1
USAGE: $progname infile [outfile]
USAGE: takepicture [-h or -help]
OPTIONS:
MESSAGE1
exit 1
}
help()
{
echo >&2 ""
echo >&2 "$progname:" "$@"
cat >&2 << MESSAGE2
NAME: takepicture
PURPOSE: digital simulation of film negative for testing purposes, point the camera at jpg and take a picture
Arguments:
MESSAGE2
exit 1
}
function DEBUG()
{
[ ! "$debug" -eq 0 ] && $@
}
function cleanup {
if [ ! -z "$tmpfileprefix" ] && [ "$debug" -eq 0 ]; then
rm -f "$tmpfileprefix"*
fi
exit 0
}
trap cleanup 0 1 2 3 6
tmpdir="./"
debug=0
tmpprefix=$tmpdir"_tp_"
comment="Processed with takepicture"
prof_dir=$HOME/.scantools
zip="-compress zip"
showtmp=0
while [ $# -gt 0 ]
do
# get parameters
case "$1" in
-h|-help) # help information
echo ""
help
;;
-d) debug=1
;;
-) # STDIN and end of arguments
break
;;
-*) # any other - argument
echo "--- UNKNOWN OPTION ---" $1
usage
;;
*) # end of arguments
break
;;
esac
shift # next option
done
infile=$1
outfile=$2
if [ -z $infile ]; then
echo "must provide a filename"
usage
fi
if [ ! -f "$infile" -o ! -r "$infile" ]; then
echo "Cannot open: $infile"
exit 1
fi
if [ -z $outfile ]; then
outfile=`basename ${infile%".jpg"}-N.tif`
fi
tmpfileprefix="$tmpprefix"`basename "${outfile%.tif}"`
DEBUG echo tmpfileprefix: $tmpfileprefix
DEBUG echo outfile: $outfile
#step to a linear capture
#convert $infile -depth 16 -fx "Fy=((u)*100+16)/116;delta=6/29;Fy>delta?Fy^3:(Fy-16/116)3*delta^2" -type TrueColor "$tmpfileprefix"_linear_cap.tif
convert $infile -depth 16 -type TrueColor -colorspace RGB "$tmpfileprefix"_linear_cap.tif
#next invert
DEBUG set -x
#Vision 3 Dmax from H-387
r_base=0.152
g_base=0.582
b_base=0.845
min_exp=`convert -size 1x1 xc: -format\
"%[fx: 1/255 ]" \
info:`
scale=1
convert "$tmpfileprefix"_linear_cap.tif -strip \
-channel R -fx "density=-log($min_exp)-(-log(u));density=density>0?density:0;densitygamma=density*0.6;filmdensity=densitygamma+$r_base;opacity=10^(-filmdensity);$scale*opacity" \
-channel G -fx "density=-log($min_exp)-(-log(u));density=density>0?density:0;densitygamma=density*0.6;filmdensity=densitygamma+$g_base;opacity=10^(-filmdensity);$scale*opacity" \
-channel B -fx "density=-log($min_exp)-(-log(u));density=density>0?density:0;densitygamma=density*0.6;filmdensity=densitygamma+$b_base;opacity=10^(-filmdensity);$scale*opacity" \
-set comment "$comment" "$tmpfileprefix"_linear_inverted.tif
convert "$tmpfileprefix"_linear_inverted.tif -set colorspace RGB -colorspace sRGB -set comment "$comment" $outfile
exit 0