Skip to content

Commit 6341a0a

Browse files
committed
fujifilm-dynamic-range: better logging and error handling
Use dt.print_log() for log messages. Print error output if no results or results not parseable from exiftool. Also update the date, it's 2021.
1 parent 952b8b2 commit 6341a0a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

contrib/fujifilm_dynamic_range.lua

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Compensate for Fujifilm raw files made using "dynamic range".
44
5-
Copyright (C) 2020 Dan Torop <[email protected]>
5+
Copyright (C) 2021 Dan Torop <[email protected]>
66
77
This program is free software; you can redistribute it and/or modify
88
it under the terms of the GNU General Public License as published by
@@ -78,23 +78,29 @@ local function detect_dynamic_range(event, image)
7878
local RAF_filename = df.sanitize_filename(tostring(image))
7979
-- without -n flag, exiftool will round to the nearest tenth
8080
local command = "exiftool -RawExposureBias -n -t " .. RAF_filename
81-
dt.print_error(command)
81+
dt.print_log(command)
8282
output = io.popen(command)
8383
local raf_result = output:read("*all")
8484
output:close()
8585
if string.len(raf_result) > 0 then
8686
raf_result = string.match(raf_result, "\t(.*)")
87-
if image.exif_exposure_bias ~= image.exif_exposure_bias then
88-
-- is NAN (this is unlikely as RAFs should have ExposureBiasValue set)
89-
image.exif_exposure_bias = 0
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."))
9098
end
91-
-- this should be auto-applied if plugins/darkroom/workflow is scene-referred
92-
-- note that scene-referred workflow exposure preset also pushes exposure up by 0.5 EV
93-
image.exif_exposure_bias = image.exif_exposure_bias + tonumber(raf_result)
94-
dt.print_error(_("Using RAF exposure bias: ") .. tostring(raf_result))
99+
else
100+
dt.print_error(_("No output returned by exiftool."))
95101
end
96102
end
97103

98104
dt.register_event("post-import-image", detect_dynamic_range)
99105

100-
print(_("fujifilm_dynamic_range loaded."))
106+
dt.print_log(_("fujifilm_dynamic_range loaded."))

0 commit comments

Comments
 (0)