Am 05.11.2017 um 19:29 schrieb Tobias Ellinghaus:
>
>> This is maybee a question for the developers:
>> Is it possible to code a lua-script, that sets the jpg images of all
>> selected groups as group header?
> Yes, it's possible.
Yay! Here's my try at it:
---SCHNIPP---
local dt = require "darktable"
-- function to get number of images in group
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count-1
end
-- function to check if a string ends with JPG
function string.ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
-- brings the jpg of a raw+jpg group to the front of the group stack
local function jpgs_2_front()
local images = dt.gui.action_images
-- check if there are selected images
if next(images) == nil then
dt.print("no images selected")
return true
end
for _, i in ipairs(images) do
local members = i:get_group_members()
-- check if the group size is 2
if tablelength(members) == 2 then
for _, m in ipairs(members) do
if string.ends(tostring(m),"JPG") then
m:make_group_leader()
end
end
end
end
end
dt.register_event("shortcut",function(event, shortcut)
jpgs_2_front()
end, "JPGs to the front of group")
--- SCHNAPP ---
It seems to work, although it definitively has it's weak points:
- You need to toggle grouping on and off to actually see the change.
- No check, whether the second file in the group is actually a raw-file
- my poor coding style ;-)
- ...
>> Or: Is it planned to add this feature (preference checkbox "jpg to
>> front") in the future? Then this workaround wouldn't be reasonable...
> No, it's not planned.
That's sad :/
My script feels a little unprofessional (This was the first time I tried
to code lua). I think I'm not the only RAW+JPG shooter out there, and
the option to choose a default might benefit others too... but maybe
someone else can use my script (or improve it ;-) )
Regards,
Felix
____________________________________________________________________________
darktable user mailing list
to unsubscribe send a mail to [email protected]