Skip to content

Commit e8a99c8

Browse files
committed
contrib/RL_out_sharp - add function to preserve the exported images
metadata in the sharpened image using exiftool
1 parent 7c93868 commit e8a99c8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

contrib/RL_out_sharp.lua

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,18 @@ if not dt.preferences.read(MODULE_NAME, "initialized", "bool") then
9999
dt.preferences.write(MODULE_NAME, "iterations", "string", "10")
100100
dt.preferences.write(MODULE_NAME, "jpg_quality", "string", "95")
101101
dt.preferences.write(MODULE_NAME, "initialized", "bool", true)
102-
end
102+
end
103+
104+
-- preserve original image metadata in the output image -----------------------
105+
local function preserve_metadata(original, sharpened)
106+
local exiftool = df.check_if_bin_exists("exiftool")
107+
108+
if exiftool then
109+
dtsys.external_command("exiftool -overwrite_original_in_place -tagsFromFile " .. original .. " " .. sharpened)
110+
else
111+
dt.print_log(MODULE .. " exiftool not found, metadata not preserved")
112+
end
113+
end
103114

104115

105116
-- setup export ---------------------------------------------------------------
@@ -163,7 +174,10 @@ local function export2RL(storage, image_table, extra_data)
163174
if result ~= 0 then
164175
dt.print(_("sharpening error"))
165176
return
166-
end
177+
end
178+
179+
-- copy metadata from input_file to output_file
180+
preserve_metadata(input_file, output_file)
167181

168182
-- delete temp image
169183
os.remove(temp_name)

0 commit comments

Comments
 (0)