fujifilm-dynamic-range: better exiftool parsing & comments
Get tab-delimited output from exiftool without rounding. Add comments to explain the choice of tags being read and tool to read them.
This commit is contained in:
@@ -28,6 +28,33 @@ Dependencies:
|
||||
|
||||
Based upon fujifilm_ratings by Ben Mendis
|
||||
|
||||
The relevant tag is RawExposureBias (0x9650). This appears to
|
||||
represent the shift in EV for the chosen DR setting (whether manual or
|
||||
automatic). Note that even at 100DR ("standard") there is an EV shift:
|
||||
|
||||
100 DR -> -0.72 EV
|
||||
200 DR -> -1.72 EV
|
||||
400 DR -> -2.72 EV
|
||||
|
||||
The ideal would be to use exiv2 to read this tag, as this is the same
|
||||
code which darktable import uses. Unfortunately, exiv2 as of v0.27.3
|
||||
can't read this tag. As it is encoded as a 4-byte ratio of two signed
|
||||
shorts -- a novel data type -- it will require some attention to fix
|
||||
this.
|
||||
|
||||
There is an exiv2-readable DevelopmentDynamicRange tag which maps to
|
||||
RawExposureBias as above. DevelopmentDynamicRange is only present
|
||||
when tag DynamicRangeSetting (0x1402) is Manual/Raw (0x0001). When it
|
||||
is Auto (0x0000), the equivalent data is tag AutoDynamicRange
|
||||
(0x140b). But exiv2 currently can't read that tag either.
|
||||
|
||||
Hence for now this code uses exiftool to read RawExposureBias, as a
|
||||
more general solution. As exiftool is approx. 10x slower than exiv2
|
||||
(Perl vs. C++), this may slow large imports.
|
||||
|
||||
These tags have been checked on a Fujifilm X100S and X100V. Other
|
||||
cameras may behave in other ways.
|
||||
|
||||
--]]
|
||||
|
||||
local dt = require "darktable"
|
||||
@@ -44,25 +71,25 @@ local function _(msgid)
|
||||
end
|
||||
|
||||
local function detect_dynamic_range(event, image)
|
||||
-- exiftool knows about the RawExposureBias tag, unlike exiv2, but it is also 10x slower
|
||||
if not df.check_if_bin_exists("exiftool") then
|
||||
dt.print_error(_("exiftool not found"))
|
||||
return
|
||||
end
|
||||
local RAF_filename = df.sanitize_filename(tostring(image))
|
||||
local command = "exiftool -RawExposureBias " .. RAF_filename
|
||||
-- without -n flag, exiftool will round to the nearest tenth
|
||||
local command = "exiftool -RawExposureBias -n -t " .. RAF_filename
|
||||
dt.print_error(command)
|
||||
output = io.popen(command)
|
||||
local raf_result = output:read("*all")
|
||||
output:close()
|
||||
if string.len(raf_result) > 0 then
|
||||
raf_result = string.gsub(raf_result, "^Raw Exposure Bias.-([%d%.%-]+)", "%1")
|
||||
raf_result = string.match(raf_result, "\t(.*)")
|
||||
if image.exif_exposure_bias ~= image.exif_exposure_bias then
|
||||
-- is NAN (this is unlikely as RAFs should have ExposureBiasValue set)
|
||||
image.exif_exposure_bias = 0
|
||||
end
|
||||
-- this should be auto-applied if plugins/darkroom/workflow is scene-referred
|
||||
-- FIXME: scene-referred workflow pushes exposure up 0.5 EV, but DR100 pushes up 0.7 EV -- should reduce this by 0.5 EV?
|
||||
-- note that scene-referred workflow exposure preset also pushes exposure up by 0.5 EV
|
||||
image.exif_exposure_bias = image.exif_exposure_bias + tonumber(raf_result)
|
||||
dt.print_error(_("Using RAF exposure bias: ") .. tostring(raf_result))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user