Skip to content

Commit 025f429

Browse files
authored
Merge pull request darktable-org#435 from ddittmar/feature/select_non_existing
select non-existing images
2 parents 867c49b + dc50d40 commit 025f429

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ change_group_leader|Yes|LMW|Change which image leads group
6666
[rename_images](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/rename_images)|Yes|LMW|Rename single or multiple images
6767
[rename-tags](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/rename-tags)|Yes|LMW|Change a tag name
6868
[RL_out_sharp](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/rl_out_sharp)|No|LW|Output sharpening using GMic (Richardson-Lucy algorithm)
69+
[select_non_existing](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/select_non_existing)|Yes|LMW|Enable selection of non-existing images in the the currently worked on images
6970
[select_untagged](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/select_untagged)|Yes|LMW|Enable selection of untagged images
7071
[slideshowMusic](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/slideshowMusic)|No|L|Play music during a slideshow
7172
[transfer_hierarchy](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/transfer_hierarchy)|Yes|LMW|Image move/copy preserving directory hierarchy

contrib/select_non_existing.lua

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
--[[
2+
This file is part of darktable,
3+
copyright (c) 2023 Dirk Dittmar
4+
5+
darktable is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
darktable is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
You should have received a copy of the GNU General Public License
14+
along with darktable. If not, see <http://www.gnu.org/licenses/>.
15+
]]
16+
--[[
17+
Enable selection of non-existing images in the the currently worked on images, e.g. the ones selected by the collection module.
18+
]]
19+
20+
local dt = require "darktable"
21+
local du = require "lib/dtutils"
22+
local df = require "lib/dtutils.file"
23+
24+
-- module name
25+
local MODULE = "select_non_existing"
26+
27+
du.check_min_api_version("9.1.0", MODULE)
28+
29+
-- figure out the path separator
30+
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
31+
32+
local gettext = dt.gettext
33+
gettext.bindtextdomain(MODULE, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
34+
35+
local function _(msgid)
36+
return gettext.dgettext(MODULE, msgid)
37+
end
38+
39+
local function stop_job(job)
40+
job.valid = false
41+
end
42+
43+
local function select_nonexisting_images(event, images)
44+
local selection = {}
45+
46+
local job = dt.gui.create_job(_("select non existing images"), true, stop_job)
47+
for key,image in ipairs(images) do
48+
if(job.valid) then
49+
job.percent = (key - 1)/#images
50+
local filepath = image.path..PS..image.filename
51+
local file_exists = df.test_file(filepath, "e")
52+
dt.print_log(filepath.." exists? => "..tostring(file_exists))
53+
if (not file_exists) then
54+
table.insert(selection, image)
55+
end
56+
else
57+
break
58+
end
59+
end
60+
stop_job(job)
61+
62+
return selection
63+
end
64+
65+
local function destroy()
66+
dt.gui.libs.select.destroy_selection(MODULE)
67+
end
68+
69+
dt.gui.libs.select.register_selection(
70+
MODULE,
71+
_("select non existing"),
72+
select_nonexisting_images,
73+
_("select all non-existing images in the current images"))
74+
75+
local script_data = {}
76+
script_data.destroy = destroy
77+
return script_data
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
msgid ""
2+
msgstr ""
3+
"Content-Type: text/plain; charset=UTF-8\n"
4+
5+
msgid "select non existing images"
6+
msgstr "nicht vorhandene Bilder auswählen"
7+
8+
msgid "select non existing"
9+
msgstr "nicht vorhandene auswählen"
10+
11+
msgid "select all non-existing images in the current images"
12+
msgstr "alle nicht vorhandenen Bilder in den aktuellen Bildern auswählen"

0 commit comments

Comments
 (0)