@@ -71,8 +71,17 @@ local function _(msgid)
71
71
end
72
72
73
73
local function detect_dynamic_range (event , image )
74
+ if image .exif_maker ~= " FUJIFILM" then
75
+ dt .print_log (_ (" [fujifilm_dynamic_range] ignoring non-Fujifilm image" ))
76
+ return
77
+ end
78
+ -- it would be nice to check image.is_raw but this appears to not yet be set
79
+ if not string.match (image .filename , " %.RAF$" ) then
80
+ dt .print_log (_ (" [fujifilm_dynamic_range] ignoring non-raw image" ))
81
+ return
82
+ end
74
83
if not df .check_if_bin_exists (" exiftool" ) then
75
- dt .print_error (_ (" exiftool not found" ))
84
+ dt .print_error (_ (" [fujifilm_dynamic_range] exiftool not found" ))
76
85
return
77
86
end
78
87
local RAF_filename = df .sanitize_filename (tostring (image ))
@@ -82,25 +91,25 @@ local function detect_dynamic_range(event, image)
82
91
output = io.popen (command )
83
92
local raf_result = output :read (" *all" )
84
93
output :close ()
85
- if string.len (raf_result ) > 0 then
86
- raf_result = string.match (raf_result , " \t (.*)" )
87
- if raf_result then
88
- if image .exif_exposure_bias ~= image .exif_exposure_bias then
89
- -- is NAN (this is unlikely as RAFs should have ExposureBiasValue set)
90
- image .exif_exposure_bias = 0
91
- end
92
- -- this should be auto-applied if plugins/darkroom/workflow is scene-referred
93
- -- note that scene-referred workflow exposure preset also pushes exposure up by 0.5 EV
94
- image .exif_exposure_bias = image .exif_exposure_bias + tonumber (raf_result )
95
- dt .print_log (_ (" Using RAF exposure bias: " ) .. tostring (raf_result ))
96
- else
97
- dt .print_error (_ (" Could not parse exiftool output." ))
98
- end
99
- else
100
- dt .print_error (_ (" No output returned by exiftool." ))
94
+ if # raf_result == 0 then
95
+ dt .print_error (_ (" [fujifilm_dynamic_range] no output returned by exiftool" ))
96
+ return
97
+ end
98
+ raf_result = string.match (raf_result , " \t (.*)" )
99
+ if not raf_result then
100
+ dt .print_error (_ (" [fujifilm_dynamic_range] could not parse exiftool output" ))
101
+ return
102
+ end
103
+ if image .exif_exposure_bias ~= image .exif_exposure_bias then
104
+ -- is NAN (this is unlikely as RAFs should have ExposureBiasValue set)
105
+ image .exif_exposure_bias = 0
101
106
end
107
+ -- this should be auto-applied if plugins/darkroom/workflow is scene-referred
108
+ -- note that scene-referred workflow exposure preset also pushes exposure up by 0.5 EV
109
+ image .exif_exposure_bias = image .exif_exposure_bias + tonumber (raf_result )
110
+ dt .print_log (_ (" [fujifilm_dynamic_range] raw exposure bias " ) .. tostring (raf_result ))
102
111
end
103
112
104
113
dt .register_event (" post-import-image" , detect_dynamic_range )
105
114
106
- dt .print_log (_ (" fujifilm_dynamic_range loaded. " ))
115
+ dt .print_log (_ (" [ fujifilm_dynamic_range] loaded" ))
0 commit comments