Hi all,
I am running bleeding edge darktable and trying to automate some procedures like mailing an image to my blog.
With this task I got stuck trying to duplicate an image via lua (Background: I want to “freeze” the published version, and with the lack of “lock” or “freeze” in dt, the best solution is to tag the published version accordingly and create a duplicate as a basis for further processing)
This is what I got so far:
Hi,
I’ve tried the way as wpferguson mentioned, but the duplicated images will be weird, the modules were triple times than in the original one. In styles I set the mode to overwrite.
local selectedImages = dt.gui.selection()
if selectedImages then
for _, image in pairs(selectedImages) do
local newimg = dt.database.duplicate(image)
local tmpstyle = dt.styles.create(image)
dt.styles.apply(tmpstyle, newimg)
dt.styles.delete(tmpstyle)
end
end
I’ve tried to replace the duplicate function with this, but this resulted to fail to load the script.
local newimg = dt.database.duplicate_image_with_history(image)
Hi,
When I wrote my first answer I had version 4.6.x, I just updated to the latest 4.8.1, but it still failed to load even with local newimg = image:duplicate_image_with_history().
So I’ve tried what springm wrote, so my working code is this:
Thanks both of you for helping.
local dt = require "darktable"
local MODULE = "my_duplicate_script"
local selectedImages = dt.gui.selection()
if selectedImages then
for _, image in pairs(selectedImages) do
local newimg = image.duplicate_with_history(image)
end
end
local function destroy()
darktable.destroy_event(MODULE .. "_my_duplicate_script", "shortcut")
end
darktable.register_event(MODULE .. "_my_duplicate_script", "shortcut",
function(event, shortcut)
end, "my_duplicate_script"
)
local script_data = {}
script_data.destroy = destroy
return script_data