From faa4e1e291d197d37be36ecf5d506d3f4375c45b Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:41:10 +0100 Subject: [PATCH] Scripts that adds shortcuts to select images with or without GPS informations --- contrib/gps_select.lua | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 contrib/gps_select.lua diff --git a/contrib/gps_select.lua b/contrib/gps_select.lua new file mode 100644 index 0000000..abb3032 --- /dev/null +++ b/contrib/gps_select.lua @@ -0,0 +1,53 @@ +--[[ + This file is part of darktable, + Copyright 2014 by Tobias Jakobs. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +]] +--[[ +darktable select images with or without GPS informations + +USAGE +* require this script from your main lua file +* register a shortcuts +]] + +dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) +table = require "table" + +function isnan(x) return x ~= x end + +local function selectWithGPS() + local selection = {} + for _,image in ipairs(dt.database) do + if (not isnan(image.longitude) and not isnan(image.latitude)) then + table.insert(selection,image) + end + end + dt.gui.selection(selection) +end + +local function selectWithoutGPS() + local selection = {} + for _,image in ipairs(dt.database) do + if (isnan(image.longitude) and isnan(image.latitude)) then + table.insert(selection,image) + end + end + dt.gui.selection(selection) +end + +dt.register_event("shortcut", selectWithGPS, "Select all images with GPS information") +dt.register_event("shortcut", selectWithoutGPS, "Select all images without GPS information")