|
2 | 2 |
|
3 | 3 | Compensate for Fujifilm raw files made using "dynamic range".
|
4 | 4 |
|
5 |
| -Copyright (C) 2020 Dan Torop <[email protected]> |
| 5 | +Copyright (C) 2021 Dan Torop <[email protected]> |
6 | 6 |
|
7 | 7 | This program is free software; you can redistribute it and/or modify
|
8 | 8 | it under the terms of the GNU General Public License as published by
|
@@ -78,23 +78,29 @@ local function detect_dynamic_range(event, image)
|
78 | 78 | local RAF_filename = df.sanitize_filename(tostring(image))
|
79 | 79 | -- without -n flag, exiftool will round to the nearest tenth
|
80 | 80 | local command = "exiftool -RawExposureBias -n -t " .. RAF_filename
|
81 |
| - dt.print_error(command) |
| 81 | + dt.print_log(command) |
82 | 82 | output = io.popen(command)
|
83 | 83 | local raf_result = output:read("*all")
|
84 | 84 | output:close()
|
85 | 85 | if string.len(raf_result) > 0 then
|
86 | 86 | 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.")) |
90 | 98 | 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.")) |
95 | 101 | end
|
96 | 102 | end
|
97 | 103 |
|
98 | 104 | dt.register_event("post-import-image", detect_dynamic_range)
|
99 | 105 |
|
100 |
| -print(_("fujifilm_dynamic_range loaded.")) |
| 106 | +dt.print_log(_("fujifilm_dynamic_range loaded.")) |
0 commit comments