From 70415b228da01d84109be808ee24b3402f2cf12f Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:39:36 +0100 Subject: [PATCH 01/24] Simple script to show the Lua API version in the preferences --- contrib/api_version.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 contrib/api_version.lua diff --git a/contrib/api_version.lua b/contrib/api_version.lua new file mode 100644 index 0000000..390f111 --- /dev/null +++ b/contrib/api_version.lua @@ -0,0 +1,28 @@ +--[[ + 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 script to show the Lua API version in the preferences + +USAGE +* require this script from your main lua file +]] +dt = require "darktable" + +local result = dt.configuration.api_version_string +dt.preferences.register("API_TEST", "API Version"..result, "string", "API Version String", "", result) + From 5da8e36c012677fd5c2a5e78c9fff589f2b5db7e Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:40:17 +0100 Subject: [PATCH 02/24] This script calcs the distance between two images using the GPS data in the metadata --- contrib/calcDistance.lua | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 contrib/calcDistance.lua diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua new file mode 100644 index 0000000..fb129aa --- /dev/null +++ b/contrib/calcDistance.lua @@ -0,0 +1,82 @@ +--[[ + 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 calc distance script + +This script calcs the distance between two images using the GPS data in the metadata + +USAGE +* require this script from your main lua file +* register a shortcut +]] + +dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +function isnan(x) return x ~= x end + +local function calcDistance() + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local lat2 = 0; + local lon2 = 0; + local i = 0; + + local sel_images = dt.gui.selection() + + for _,image in ipairs(sel_images) do + if ((not isnan(image.longitude) and not isnan(image.latitude)) and + (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + + i = i + 1; + + if (i == 1) then + lat1 = image.latitude; + lon1 = image.longitude; + end + + lat2 = image.latitude; + lon2 = image.longitude; + + end + end + +-- I used code from here: +-- http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points + + local earthRadius = 6371; -- Radius of the earth in km + local dLat = math.rad(lat2-lat1); -- deg2rad below + local dLon = math.rad(lon2-lon1); + local a = + math.sin(dLat/2) * math.sin(dLat/2) + + math.cos(math.rad(lat1)) * math.cos(math.rad(lat2)) * + math.sin(dLon/2) * math.sin(dLon/2) + ; + local angle = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)); + local distance = earthRadius * angle; -- Distance in km + + dt.print(distance) + + +end + +-- Register +dt.register_event("shortcut",calcDistance,"Calculate the distance from latitude and longitude in km") From faa4e1e291d197d37be36ecf5d506d3f4375c45b Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:41:10 +0100 Subject: [PATCH 03/24] 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") From ecc2691bee5bfde2ab3da4101ef77467f63f9d24 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:41:33 +0100 Subject: [PATCH 04/24] darktable KML export script --- contrib/kml_export.lua | 231 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 contrib/kml_export.lua diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua new file mode 100644 index 0000000..b00b030 --- /dev/null +++ b/contrib/kml_export.lua @@ -0,0 +1,231 @@ +--[[ + 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 KML export script + +ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT +* mkdir +* zip (only if you create KMZ files) +* convert (ImageMagick) +* xdg-open +* xdg-user-dir + +WARNING +This script is only testet with Linux + +USAGE +* require this script from your main lua file +]] + +dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +function isnan(x) return x ~= x end + +function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua + -- collect the keys + local keys = {} + for _key in pairs(_table) do keys[#keys + 1] = _key end + + -- if order function given, sort by it by passing the table and keys a, b, + -- otherwise just sort the keys + if order then + table.sort(keys, function(a,b) return order(_table, a, b) end) + else + table.sort(keys) + end + + -- return the iterator function + local i = 0 + return function() + i = i + 1 + if keys[i] then + return keys[i], _table[keys[i]] + end + end +end + +local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) + dt.print("Export Image "..tostring(number).."/"..tostring(total)) +end + +local function create_kml_file(storage, image_table, extra_data) + + + + dt.print_error("Will try to export KML file now") + + if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then + exportDirectory = dt.configuration.tmp_dir + imageFoldername = "" + else + exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string") + + -- Creates dir if not exsists + imageFoldername = "files/" + local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername + coroutine.yield("run_command", mkdirCommand) + end + + + -- Create the thumbnails + for _,image in pairs(image_table) do + local path, filename, filetype = string.match(image, "(.-)([^\\/]-%.?([^%.\\/]*))$") + filename = string.upper(string.gsub(filename,"%.", "_")) + + -- convert -size 92x92 filename.jpg -resize 92x92 +profile "*" thumbnail.jpg + -- In this example, '-size 120x120' gives a hint to the JPEG decoder that the image is going to be downscaled to + -- 120x120, allowing it to run faster by avoiding returning full-resolution images to GraphicsMagick for the + -- subsequent resizing operation. The '-resize 120x120' specifies the desired dimensions of the output image. It + -- will be scaled so its largest dimension is 120 pixels. The '+profile "*"' removes any ICM, EXIF, IPTC, or other + -- profiles that might be present in the input and aren't needed in the thumbnail. + + local concertToThumbCommand = "convert -size 96x96 "..image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg" + -- USE coroutine.yield. It does not block the UI + coroutine.yield("run_command", concertToThumbCommand) + local concertCommand = "convert -size 438x438 "..image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" + coroutine.yield("run_command", concertCommand) + + local pattern = "[/]?([^/]+)$" + filmName = string.match(_.film.path, pattern) + end + + exportKMLFilename = filmName..".kml" + exportKMZFilename = filmName..".kmz" + + -- Create the KML file + kml_file = "\n" + kml_file = kml_file.."\n" + kml_file = kml_file.."\n" + + --image_table = dt.gui.selection(); + kml_file = kml_file..""..filmName.."\n" + kml_file = kml_file.." Exported from darktable\n" + + for image,_ in pairs(image_table) do + filename = string.upper(string.gsub(image.filename,"%.", "_")) + + if ((not isnan(image.longitude) and not isnan(image.latitude)) and + (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + kml_file = kml_file.." \n" + kml_file = kml_file.." "..image.filename.."\n" + --kml_file = kml_file.." \n" + + kml_file = kml_file.." \n" + + kml_file = kml_file.." \n" + kml_file = kml_file.." 1\n" + kml_file = kml_file.." "..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",0\n" + kml_file = kml_file.." \n" + kml_file = kml_file.." "..string.gsub(image.exif_datetime_taken," ", "T").."Z".."\n" + kml_file = kml_file.." \n" + kml_file = kml_file.." \n" + + kml_file = kml_file.." \n" + end + end + +-- Connects all images with an path + if ( dt.preferences.read("kml_export","CreatePath","bool") == true ) then + kml_file = kml_file.." \n" + kml_file = kml_file.." Path\n" -- ToDo: I think a better name would be nice + --kml_file = kml_file.." \n" + + kml_file = kml_file.." \n" + + kml_file = kml_file.." \n" + kml_file = kml_file.." \n" + + for image,_ in spairs(image_table, function(t,a,b) return t[b] < t[a] end) do + if ((not isnan(image.longitude) and not isnan(image.latitude)) and + (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + kml_file = kml_file.." "..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",0\n" + end + end + kml_file = kml_file.." \n" + kml_file = kml_file.." \n" + + kml_file = kml_file.." \n" + end + + kml_file = kml_file.."\n" + kml_file = kml_file.."" + + file = io.open(exportDirectory.."/"..exportKMLFilename, "w") + file:write(kml_file) + file:close() + + dt.print("KML file created in "..exportDirectory) + +-- Compress the files to create a KMZ file + if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then + exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string") + -- USE coroutine.yield. It does not block the UI + local createKMZCommand = "zip --test --move --junk-paths " + createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" " + createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..exportKMLFilename.."\" \""..dt.configuration.tmp_dir.."/"..imageFoldername.."\"*" + coroutine.yield("run_command", createKMZCommand) + end + +-- Open the file with the standard programm + if ( dt.preferences.read("kml_export","OpenKmlFile","bool") == true ) then + local kmlFileOpenCommand + + if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then + kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMZFilename.."\"" + else + kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMLFilename.."\"" + end + coroutine.yield("run_command", kmlFileOpenCommand) + end + + +end + +-- Preferences +dt.preferences.register("kml_export", "OpenKmlFile", "bool", "KML export: Open KML/KMZ file after export", "Opens the KML file after the export with the standard programm for KML files", false ) + +local handle = io.popen("xdg-user-dir DESKTOP") +local result = handle:read() +handle:close() +dt.preferences.register("kml_export", "ExportDirectory", "directory", "KML export: Export directory", "A directory that will be used to export the KML/KMZ files", result ) + +dt.preferences.register("kml_export", "CreatePath", "bool", "KML export: Connect images with path", "connect all images with a path", false ) +dt.preferences.register("kml_export", "CreateKMZ", "bool", "KML export: Create KMZ file", "Compress all imeges to one KMZ file", true ) + +-- Register +dt.register_storage("kml_export", "KML/KMZ Export", nil, create_kml_file) + From b40b1e0b1c57c878df1ea428b17294f22dc89281 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:41:54 +0100 Subject: [PATCH 05/24] darktable script to show the different prefference types that are possible with the Lua --- contrib/preferenceExcamples.lua | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 contrib/preferenceExcamples.lua diff --git a/contrib/preferenceExcamples.lua b/contrib/preferenceExcamples.lua new file mode 100644 index 0000000..c6f9ae0 --- /dev/null +++ b/contrib/preferenceExcamples.lua @@ -0,0 +1,81 @@ +--[[ + 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 script to show the different prefference types that are possible with the Lua + +USAGE +* require this script from your main lua file +]] +dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExcamplesString", -- name + "string", -- type + "Excample String", -- label + "Excample String Tooltip", -- tooltip + "String") -- default + +dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExcamplesString", -- name + "bool", -- type + "Excample Boolean", -- label + "Excample Boolean Tooltip", -- tooltip + true) -- default + +dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExcamplesString", -- name + "integer", -- type + "Excample Integer", -- label + "Excample Integer Tooltip", -- tooltip + 2, -- default + 1, -- min + 99) -- max + +dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExcamplesString", -- name + "float", -- type + "Excample Float", -- label + "Excample Float Tooltip", -- tooltip + 1.3, -- default + 1, -- min + 99, -- max + 0.5) -- step + +dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExcamplesString", -- name + "file", -- type + "Excample File", -- label + "Excample File Tooltip", -- tooltip + "") -- default + +dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExcamplesString", -- name + "directory", -- type + "Excample Directory", -- label + "Excample Directory Tooltip", -- tooltip + "") -- default + +dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExcamplesString", -- name + "enum", -- type + "Excample Enum", -- label + "Excample Enum Tooltip", -- tooltip + "Enum 1", -- default + "Enum 1", "Enum 2") -- values + From 0bf51134961fadf08c74cc8379c9c56e6279a88c Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:42:18 +0100 Subject: [PATCH 06/24] darktable Script to play music during a Slideshow --- contrib/slideshowMusic.lua | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 contrib/slideshowMusic.lua diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua new file mode 100644 index 0000000..9a41021 --- /dev/null +++ b/contrib/slideshowMusic.lua @@ -0,0 +1,55 @@ +--[[ + 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 Script to play music during a Slideshow + +You need rhythmbox-client installed to use this script + +USAGE +* require this script from your main lua file +]] + +dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +local function playSlideshowMusic(_, old_view, new_view) + local filename + + filename = dt.preferences.read("slideshowMusic","SlideshowMusic","string") + + local playCommand, stopCommand + + if (new_view.id == "slideshow") then + playCommand = 'rhythmbox-client --play-uri="'..filename..'"' + + dt.print_error(playCommand) + os.execute(playCommand) + --coroutine.yield("RUN_COMMAND", playCommand) + else + stopCommand = "rhythmbox-client --pause" + dt.print_error(stopCommand) + os.execute(stopCommand) + --coroutine.yield("RUN_COMMAND", stopCommand) + end +end + +-- Preferences +dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", "Slideshow background music file", "", "") + +-- Register +dt.register_event("view-changed",playSlideshowMusic) From cf16e71ee10baed28a4dc895c59530725b760cd9 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Mon, 22 Dec 2014 20:43:04 +0100 Subject: [PATCH 07/24] darktable (timelaps) video export script --- contrib/video.lua | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 contrib/video.lua diff --git a/contrib/video.lua b/contrib/video.lua new file mode 100644 index 0000000..830823f --- /dev/null +++ b/contrib/video.lua @@ -0,0 +1,96 @@ +--[[ + 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 video export script + +ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT +* mencoder (MEncoder is from the MPlayer Team) +* xdg-open +* xdg-user-dir + +WARNING +This script is only testet with Linux + +USAGE +* require this script from your main lua file +]] + +dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) + dt.print("Export Image "..tostring(number).."/"..tostring(total)) +end + +local function create_video(storage, image_table, extra_data) + + exportDirectory = dt.preferences.read("video","ExportDirectory","string") + exportFilename = "output.avi" + framsePerSecond = dt.preferences.read("video","FramesPerSecond","integer") + + dt.print_error("Will try to create video now") + -- Set the codec + local codec = "" + local codecPreferences = "" + + codecPreferences = dt.preferences.read("video","Codec","string") + if (codecPreferences == "H.264 encoding") then + codec = 'x264' + end + if (codecPreferences == "XviD encoding") then + codec = 'xvid' + end + if not codecPreferences then + codec = 'x264' + end + + -- Create the command + local command = "mencoder -idx -nosound -noskip -ovc "..codec.." -lavcopts vcodec=mjpeg -o "..exportDirectory.."/"..exportFilename.." -mf fps="..framsePerSecond .." mf://" + + for _,v in pairs(image_table) do + command = command..v.."," + end + + dt.print_error("this is the command: "..command) + -- USE coroutine.yield. It does not block the UI + coroutine.yield("run_command", command) + + dt.print("Video created in "..exportDirectory) + + if ( dt.preferences.read("video","OpenVideo","bool") == true ) then + -- USE coroutine.yield. It does not block the UI + local playVideoCommand = "xdg-open "..exportDirectory.."/"..exportFilename + coroutine.yield("run_command", playVideoCommand) + end +end + +-- Preferences +dt.preferences.register("video", "FramesPerSecond", "float", "Video exort: Frames per second", "Frames per Second in the Video export", 15, 1, 99, 0.1 ) +dt.preferences.register("video", "OpenVideo", "bool", "Video exort: Open video after export", "Opens the Video after the export with the standard video player", false ) + +local handle = io.popen("xdg-user-dir VIDEOS") +local result = handle:read() +handle:close() +dt.preferences.register("video", "ExportDirectory", "directory", "Video exort: Video export directory","A directory that will be used to export a Video",result) + +-- Get the MEncoder codec list with: mencoder -ovc help +dt.preferences.register("video", "Codec", "enum", "Video exort: Codec","Video codec","H.264 encoding","H.264 encoding","XviD encoding") + +-- Register +dt.register_storage("video", "Video Export", show_status, create_video) + From a262682419dd7af62ca3cd677718747da8382185 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:26:37 +0100 Subject: [PATCH 08/24] Update and rename preferenceExcamples.lua to preferenceExamples.lua Fixed spelling --- contrib/preferenceExamples.lua | 81 +++++++++++++++++++++++++++++++++ contrib/preferenceExcamples.lua | 81 --------------------------------- 2 files changed, 81 insertions(+), 81 deletions(-) create mode 100644 contrib/preferenceExamples.lua delete mode 100644 contrib/preferenceExcamples.lua diff --git a/contrib/preferenceExamples.lua b/contrib/preferenceExamples.lua new file mode 100644 index 0000000..e487bf0 --- /dev/null +++ b/contrib/preferenceExamples.lua @@ -0,0 +1,81 @@ +--[[ + 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 script to show the different prefference types that are possible with the Lua + +USAGE +* require this script from your main lua file +]] +dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExamplesString", -- name + "string", -- type + "Example String", -- label + "Example String Tooltip", -- tooltip + "String") -- default + +dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExamplesString", -- name + "bool", -- type + "Example Boolean", -- label + "Example Boolean Tooltip", -- tooltip + true) -- default + +dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExamplesString", -- name + "integer", -- type + "Example Integer", -- label + "Example Integer Tooltip", -- tooltip + 2, -- default + 1, -- min + 99) -- max + +dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExamplesString", -- name + "float", -- type + "Example Float", -- label + "Example Float Tooltip", -- tooltip + 1.3, -- default + 1, -- min + 99, -- max + 0.5) -- step + +dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExamplesString", -- name + "file", -- type + "Example File", -- label + "Example File Tooltip", -- tooltip + "") -- default + +dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExamplesString", -- name + "directory", -- type + "Example Directory", -- label + "Example Directory Tooltip", -- tooltip + "") -- default + +dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. + "preferenceExamplesString", -- name + "enum", -- type + "Example Enum", -- label + "Example Enum Tooltip", -- tooltip + "Enum 1", -- default + "Enum 1", "Enum 2") -- values + diff --git a/contrib/preferenceExcamples.lua b/contrib/preferenceExcamples.lua deleted file mode 100644 index c6f9ae0..0000000 --- a/contrib/preferenceExcamples.lua +++ /dev/null @@ -1,81 +0,0 @@ ---[[ - 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 script to show the different prefference types that are possible with the Lua - -USAGE -* require this script from your main lua file -]] -dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) - -dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. - "preferenceExcamplesString", -- name - "string", -- type - "Excample String", -- label - "Excample String Tooltip", -- tooltip - "String") -- default - -dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. - "preferenceExcamplesString", -- name - "bool", -- type - "Excample Boolean", -- label - "Excample Boolean Tooltip", -- tooltip - true) -- default - -dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. - "preferenceExcamplesString", -- name - "integer", -- type - "Excample Integer", -- label - "Excample Integer Tooltip", -- tooltip - 2, -- default - 1, -- min - 99) -- max - -dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. - "preferenceExcamplesString", -- name - "float", -- type - "Excample Float", -- label - "Excample Float Tooltip", -- tooltip - 1.3, -- default - 1, -- min - 99, -- max - 0.5) -- step - -dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. - "preferenceExcamplesString", -- name - "file", -- type - "Excample File", -- label - "Excample File Tooltip", -- tooltip - "") -- default - -dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. - "preferenceExcamplesString", -- name - "directory", -- type - "Excample Directory", -- label - "Excample Directory Tooltip", -- tooltip - "") -- default - -dt.preferences.register("preferenceExcamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. - "preferenceExcamplesString", -- name - "enum", -- type - "Excample Enum", -- label - "Excample Enum Tooltip", -- tooltip - "Enum 1", -- default - "Enum 1", "Enum 2") -- values - From 523b12df1b324cc09e09fb2f9f29066eba630000 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:30:56 +0100 Subject: [PATCH 09/24] Update api_version.lua Moved the output from the preferences to dt.print_error. --- contrib/api_version.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/api_version.lua b/contrib/api_version.lua index 390f111..1b18d59 100644 --- a/contrib/api_version.lua +++ b/contrib/api_version.lua @@ -24,5 +24,4 @@ USAGE dt = require "darktable" local result = dt.configuration.api_version_string -dt.preferences.register("API_TEST", "API Version"..result, "string", "API Version String", "", result) - +dt.print_error("API Version: "..result) From aeac4e10bf870d824c23e85dd55fe854a691de1d Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:33:55 +0100 Subject: [PATCH 10/24] Update calcDistance.lua Better output (distance is in km) --- contrib/calcDistance.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua index fb129aa..34330c9 100644 --- a/contrib/calcDistance.lua +++ b/contrib/calcDistance.lua @@ -73,7 +73,7 @@ local function calcDistance() local angle = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)); local distance = earthRadius * angle; -- Distance in km - dt.print(distance) + dt.print(distance.." km") end From 9cce42eb3ec68a473ad468ba61cc03ad762844c0 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:43:12 +0100 Subject: [PATCH 11/24] Update api_version.lua local dt --- contrib/api_version.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/api_version.lua b/contrib/api_version.lua index 1b18d59..971f14c 100644 --- a/contrib/api_version.lua +++ b/contrib/api_version.lua @@ -21,7 +21,7 @@ darktable script to show the Lua API version in the preferences USAGE * require this script from your main lua file ]] -dt = require "darktable" +local dt = require "darktable" local result = dt.configuration.api_version_string dt.print_error("API Version: "..result) From d7f33664d195e5a4ba5db97247b22b13b37530aa Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:43:39 +0100 Subject: [PATCH 12/24] Update calcDistance.lua local dt --- contrib/calcDistance.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua index 34330c9..453b832 100644 --- a/contrib/calcDistance.lua +++ b/contrib/calcDistance.lua @@ -25,7 +25,7 @@ USAGE * register a shortcut ]] -dt = require "darktable" +local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) function isnan(x) return x ~= x end From 719237d480a7784b53bf8032a5b20089f01e0e98 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:44:15 +0100 Subject: [PATCH 13/24] Update gps_select.lua local dt --- contrib/gps_select.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/gps_select.lua b/contrib/gps_select.lua index abb3032..02403be 100644 --- a/contrib/gps_select.lua +++ b/contrib/gps_select.lua @@ -23,7 +23,7 @@ USAGE * register a shortcuts ]] -dt = require "darktable" +local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) table = require "table" From a60aa4f7c765fd554e88d76c3d4a0a7627864ea3 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:44:53 +0100 Subject: [PATCH 14/24] Update kml_export.lua local dt --- contrib/kml_export.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index b00b030..af5ba3c 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -32,7 +32,7 @@ USAGE * require this script from your main lua file ]] -dt = require "darktable" +local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) function isnan(x) return x ~= x end From bd9359d7b14d8ec16f8257961d0d95ee9fbeb5f6 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:45:23 +0100 Subject: [PATCH 15/24] Update preferenceExamples.lua local dt --- contrib/preferenceExamples.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/preferenceExamples.lua b/contrib/preferenceExamples.lua index e487bf0..18a6553 100644 --- a/contrib/preferenceExamples.lua +++ b/contrib/preferenceExamples.lua @@ -21,7 +21,7 @@ darktable script to show the different prefference types that are possible with USAGE * require this script from your main lua file ]] -dt = require "darktable" +local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference. From 5fe3528e024497cb91983e712d1554df044f6854 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:45:45 +0100 Subject: [PATCH 16/24] Update slideshowMusic.lua local dt --- contrib/slideshowMusic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index 9a41021..564e84d 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -24,7 +24,7 @@ USAGE * require this script from your main lua file ]] -dt = require "darktable" +local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) local function playSlideshowMusic(_, old_view, new_view) From 462cceae3d50e7c102f3a237b4ef0d9580f9f077 Mon Sep 17 00:00:00 2001 From: supertobi Date: Fri, 26 Dec 2014 12:46:12 +0100 Subject: [PATCH 17/24] Update video.lua local dt --- contrib/video.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/video.lua b/contrib/video.lua index 830823f..f981f5e 100644 --- a/contrib/video.lua +++ b/contrib/video.lua @@ -30,7 +30,7 @@ USAGE * require this script from your main lua file ]] -dt = require "darktable" +local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) From b737d2878091818b6083326b60f87eb277e9c758 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Fri, 26 Dec 2014 19:05:20 +0100 Subject: [PATCH 18/24] add checkIfBinExists --- contrib/video.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/contrib/video.lua b/contrib/video.lua index f981f5e..c94ab5e 100644 --- a/contrib/video.lua +++ b/contrib/video.lua @@ -37,7 +37,29 @@ local function show_status(storage, image, format, filename, number, total, high dt.print("Export Image "..tostring(number).."/"..tostring(total)) end +local function checkIfBinExists(bin) + local handle = io.popen("which "..bin) + local result = handle:read() + local ret + handle:close() + if (not result) then + dt.print_error(bin.." not found") + ret = false + end + ret = true + return ret +end + local function create_video(storage, image_table, extra_data) + if not checkIfBinExists("mencoder") then + return + end + if not checkIfBinExists("xdg-open") then + return + end + if not checkIfBinExists("xdg-user-dir") then + return + end exportDirectory = dt.preferences.read("video","ExportDirectory","string") exportFilename = "output.avi" From 6ced2ac6c18b056759bb9eca6502e7f62403fc9f Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Fri, 26 Dec 2014 19:09:16 +0100 Subject: [PATCH 19/24] all funktions local --- contrib/kml_export.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index af5ba3c..c187c7a 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -35,9 +35,9 @@ USAGE local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) -function isnan(x) return x ~= x end +local function isnan(x) return x ~= x end -function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua +local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua -- collect the keys local keys = {} for _key in pairs(_table) do keys[#keys + 1] = _key end @@ -66,7 +66,6 @@ end local function create_kml_file(storage, image_table, extra_data) - dt.print_error("Will try to export KML file now") From fde658e499aa7ad54ae3f71729c37fd9729ba8a3 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Fri, 26 Dec 2014 19:11:19 +0100 Subject: [PATCH 20/24] add checkIfBinExists --- contrib/kml_export.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index c187c7a..d043fd4 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -64,12 +64,40 @@ local function show_status(storage, image, format, filename, number, total, high dt.print("Export Image "..tostring(number).."/"..tostring(total)) end +local function checkIfBinExists(bin) + local handle = io.popen("which "..bin) + local result = handle:read() + local ret + handle:close() + if (not result) then + dt.print_error(bin.." not found") + ret = false + end + ret = true + return ret +end + local function create_kml_file(storage, image_table, extra_data) + if not checkIfBinExists("mkdir") then + return + end + if not checkIfBinExists("convert") then + return + end + if not checkIfBinExists("xdg-open") then + return + end + if not checkIfBinExists("xdg-user-dir") then + return + end dt.print_error("Will try to export KML file now") if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then + if not checkIfBinExists("zip") then + return + end exportDirectory = dt.configuration.tmp_dir imageFoldername = "" else From 3cfb2ecfb94cd95c8ecf0cc6bf6acb31d910271c Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Fri, 26 Dec 2014 19:14:48 +0100 Subject: [PATCH 21/24] New option to enable/disable the playback --- contrib/slideshowMusic.lua | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index 564e84d..f5de473 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -25,31 +25,38 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) +dt.configuration.check_version(...,{2,0,2}) local function playSlideshowMusic(_, old_view, new_view) - local filename + local filename, playMusic filename = dt.preferences.read("slideshowMusic","SlideshowMusic","string") + playMusic = dt.preferences.read("slideshowMusic","PlaySlideshowMusic","bool") - local playCommand, stopCommand - if (new_view.id == "slideshow") then - playCommand = 'rhythmbox-client --play-uri="'..filename..'"' + if (playMusic) then + local playCommand, stopCommand + + if (new_view.id == "slideshow") then + playCommand = 'rhythmbox-client --play-uri="'..filename..'"' - dt.print_error(playCommand) - os.execute(playCommand) - --coroutine.yield("RUN_COMMAND", playCommand) - else - stopCommand = "rhythmbox-client --pause" - dt.print_error(stopCommand) - os.execute(stopCommand) - --coroutine.yield("RUN_COMMAND", stopCommand) + --dt.print_error(playCommand) + coroutine.yield("RUN_COMMAND", playCommand) + else + stopCommand = "rhythmbox-client --pause" + --dt.print_error(stopCommand) + coroutine.yield("RUN_COMMAND", stopCommand) + end end end -- Preferences dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", "Slideshow background music file", "", "") - +dt.preferences.register("slideshowMusic", + "PlaySlideshowMusic", + "bool", + "Play slideshow background music", + "Plays music with rhythmbox if a slideshow starts", + true) -- Register dt.register_event("view-changed",playSlideshowMusic) From 739317285efbb00cae3bb1c9a4c2eb8e71941650 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Fri, 26 Dec 2014 19:15:44 +0100 Subject: [PATCH 22/24] added checkIfBinExists --- contrib/slideshowMusic.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index f5de473..a66c28a 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -27,12 +27,28 @@ USAGE local dt = require "darktable" dt.configuration.check_version(...,{2,0,2}) +local function checkIfBinExists(bin) + local handle = io.popen("which "..bin) + local result = handle:read() + local ret + handle:close() + if (not result) then + dt.print_error(bin.." not found") + ret = false + end + ret = true + return ret +end + local function playSlideshowMusic(_, old_view, new_view) local filename, playMusic filename = dt.preferences.read("slideshowMusic","SlideshowMusic","string") playMusic = dt.preferences.read("slideshowMusic","PlaySlideshowMusic","bool") + if not checkIfBinExists("rhythmbox-client") then + return + end if (playMusic) then local playCommand, stopCommand From 5353cd20ff23b810459bdbae0984b9819dcecad2 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Fri, 26 Dec 2014 19:54:14 +0100 Subject: [PATCH 23/24] removed isnan --- contrib/gps_select.lua | 6 ++---- contrib/kml_export.lua | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/contrib/gps_select.lua b/contrib/gps_select.lua index 02403be..14fbf75 100644 --- a/contrib/gps_select.lua +++ b/contrib/gps_select.lua @@ -27,12 +27,10 @@ local 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 + if (image.longitude and image.latitude) then table.insert(selection,image) end end @@ -42,7 +40,7 @@ end local function selectWithoutGPS() local selection = {} for _,image in ipairs(dt.database) do - if (isnan(image.longitude) and isnan(image.latitude)) then + if (not image.longitude and not image.latitude) then table.insert(selection,image) end end diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index d043fd4..c4758fc 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -35,8 +35,6 @@ USAGE local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) -local function isnan(x) return x ~= x end - local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua -- collect the keys local keys = {} @@ -147,7 +145,7 @@ local function create_kml_file(storage, image_table, extra_data) for image,_ in pairs(image_table) do filename = string.upper(string.gsub(image.filename,"%.", "_")) - if ((not isnan(image.longitude) and not isnan(image.latitude)) and + if ((image.longitude and image.latitude) and (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data ) then kml_file = kml_file.." \n" @@ -196,7 +194,7 @@ local function create_kml_file(storage, image_table, extra_data) kml_file = kml_file.." \n" for image,_ in spairs(image_table, function(t,a,b) return t[b] < t[a] end) do - if ((not isnan(image.longitude) and not isnan(image.latitude)) and + if ((image.longitude and image.latitude) and (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data ) then kml_file = kml_file.." "..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",0\n" From 74a241a3ea99656fb6b820154e8892c745000a67 Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Fri, 26 Dec 2014 19:59:56 +0100 Subject: [PATCH 24/24] removed isnan --- contrib/calcDistance.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua index 453b832..c21dd69 100644 --- a/contrib/calcDistance.lua +++ b/contrib/calcDistance.lua @@ -28,8 +28,6 @@ USAGE local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) -function isnan(x) return x ~= x end - local function calcDistance() local sel_images = dt.gui.selection() @@ -42,7 +40,7 @@ local function calcDistance() local sel_images = dt.gui.selection() for _,image in ipairs(sel_images) do - if ((not isnan(image.longitude) and not isnan(image.latitude)) and + if ((image.longitude and image.latitude) and (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data ) then