From eff89532076f64f6ce8f08a2daa78ea0f645d918 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 15 Dec 2015 10:41:10 +0100 Subject: [PATCH 01/67] Create geo_uri.lua Maps in 3.20 will be able to handle the 'geo' URI scheme. That means that if you enter the shortcut Gnome Maps will present the current window if there is one and go to location, and start a new instance of maps if there is none. --- contrib/geo_uri.lua | 96 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 contrib/geo_uri.lua diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua new file mode 100644 index 0000000..12ac1e1 --- /dev/null +++ b/contrib/geo_uri.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 script to open a geo uri in gnome-maps + +ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT +* gnome-maps >= 3.20 + +WARNING +This script is not testet. + +USAGE +* require this script from your main lua file +* register a shortcut +]] + +local dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +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 openLocationInGnomeMaps() + if not checkIfBinExists("gnome-maps") then + darktable.print_error("gnome-maps not found") + return + end + + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local i = 0; + + local sel_images = dt.gui.selection() + +-- Use the first image with geo information + for _,image in ipairs(sel_images) do + 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 + + i = i + 1; + + if (i == 1) then + lat1 = image.latitude; + lon1 = image.longitude; + end + + end + end + + if (lat1 and lon1) then + + local startCommand + + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" + end + + dt.print_error(startCommand) + + if coroutine.yield("RUN_COMMAND", startCommand) + then + dt.print("Command failed ...") + end + + end +end + +-- Register +dt.register_event("shortcut", openLocationInGnomeMaps, "Open Location in Gnome Maps") From c56766ef8582238e50182a178233cc5d6ac70030 Mon Sep 17 00:00:00 2001 From: supertobi Date: Wed, 16 Dec 2015 13:51:35 +0100 Subject: [PATCH 02/67] Fixed spaces --- contrib/geo_uri.lua | 84 +++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 12ac1e1..57f58bf 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -33,63 +33,59 @@ local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) 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 + 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 openLocationInGnomeMaps() - if not checkIfBinExists("gnome-maps") then - darktable.print_error("gnome-maps not found") - return - end + if not checkIfBinExists("gnome-maps") then + darktable.print_error("gnome-maps not found") + return + end - local sel_images = dt.gui.selection() - - local lat1 = 0; - local lon1 = 0; - local i = 0; - - local sel_images = dt.gui.selection() - --- Use the first image with geo information - for _,image in ipairs(sel_images) do - 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 - - i = i + 1; - - if (i == 1) then - lat1 = image.latitude; - lon1 = image.longitude; - end - + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local i = 0; + + local sel_images = dt.gui.selection() + + -- Use the first image with geo information + for _,image in ipairs(sel_images) do + 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 + + i = i + 1; + + if (i == 1) then + lat1 = image.latitude; + lon1 = image.longitude; end + + end end if (lat1 and lon1) then - - local startCommand - - startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" - end - + local startCommand + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" dt.print_error(startCommand) - if coroutine.yield("RUN_COMMAND", startCommand) - then + if coroutine.yield("RUN_COMMAND", startCommand) then dt.print("Command failed ...") end - end + + end end -- Register From 92dcb2901043ab9dd46316f1e7b1e3270c0e7f41 Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 4 Jan 2016 22:52:31 +0100 Subject: [PATCH 03/67] Update slideshowMusic.lua Test if old_view is nil --- contrib/slideshowMusic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index d5575a2..0ba09d9 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -59,7 +59,7 @@ local function playSlideshowMusic(_, old_view, new_view) --dt.print_error(playCommand) coroutine.yield("RUN_COMMAND", playCommand) else - if (old_view.id == "slideshow") then + if (old_view and old_view.id == "slideshow") then stopCommand = "rhythmbox-client --pause" --dt.print_error(stopCommand) coroutine.yield("RUN_COMMAND", stopCommand) From d2a34226a6cbf4055d1d1e99b434451be82b47f7 Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 4 Jan 2016 22:53:10 +0100 Subject: [PATCH 04/67] Update slideshowMusic.lua Tested with darktable 2.0 --- contrib/slideshowMusic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index 0ba09d9..3ba8944 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -25,7 +25,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,2}) +dt.configuration.check_version(...,{2,0,2},{3,0,0}) local function checkIfBinExists(bin) local handle = io.popen("which "..bin) From 2e0ccef3f569b9d0943539a2d12e7d3b97dec769 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 5 Jan 2016 10:22:47 +0100 Subject: [PATCH 05/67] Update geo_uri.lua Changes suggested from Boucman --- contrib/geo_uri.lua | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 57f58bf..857ae61 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -1,6 +1,6 @@ --[[ This file is part of darktable, - Copyright 2014 by Tobias Jakobs. + Copyright 2016 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 @@ -30,7 +30,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) +dt.configuration.check_version(...,{3,0,0}) local function checkIfBinExists(bin) local handle = io.popen("which "..bin) @@ -57,34 +57,25 @@ local function openLocationInGnomeMaps() local lon1 = 0; local i = 0; - local sel_images = dt.gui.selection() - -- Use the first image with geo information for _,image in ipairs(sel_images) do 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 - - i = i + 1; - - if (i == 1) then - lat1 = image.latitude; - lon1 = image.longitude; - end - + lat1 = image.latitude; + lon1 = image.longitude; + break end end - if (lat1 and lon1) then - local startCommand - startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" - dt.print_error(startCommand) + local startCommand + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" + dt.print_error(startCommand) - if coroutine.yield("RUN_COMMAND", startCommand) then - dt.print("Command failed ...") - end + if coroutine.yield("RUN_COMMAND", startCommand) then + dt.print("Command failed ...") end - + end end From eff4a3abcbd27aa1d79e221f436ff3999d08ad34 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 5 Jan 2016 10:28:31 +0100 Subject: [PATCH 06/67] Update geo_uri.lua removed the old warning --- contrib/geo_uri.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 857ae61..34ed1c4 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -21,9 +21,6 @@ darktable script to open a geo uri in gnome-maps ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT * gnome-maps >= 3.20 -WARNING -This script is not testet. - USAGE * require this script from your main lua file * register a shortcut From cba5c65608a1f601627d905d6af65a25c68e4d89 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 5 Jan 2016 22:05:18 +0100 Subject: [PATCH 07/67] Update gps_select.lua Tested with darktable 2.0 --- 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 14fbf75..6955971 100644 --- a/contrib/gps_select.lua +++ b/contrib/gps_select.lua @@ -24,7 +24,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) +dt.configuration.check_version(...,{2,0,1},{3,0,0}) table = require "table" local function selectWithGPS() From a819140c88a2436e83035ca1b0799103a71727df Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 5 Jan 2016 22:12:57 +0100 Subject: [PATCH 08/67] Update hugin.lua Tested with darktable 2.0 --- contrib/hugin.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/hugin.lua b/contrib/hugin.lua index 819e5b2..40c2371 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -35,8 +35,8 @@ This plugin will add a new storage option and calls hugin after export. local dt = require "darktable" --- should work with darktable API version 2.0.0 -dt.configuration.check_version(...,{2,0,0}) +-- works with darktable API version 2.0.0 and 3.0.0 +dt.configuration.check_version(...,{2,0,0},{3,0,0}) local function checkIfBinExists(bin) local handle = io.popen("which "..bin) From 1d3a44a157a570abd4d474b51d41fd5dd47b1c81 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 7 Jan 2016 09:08:35 +0100 Subject: [PATCH 09/67] Update calcDistance.lua Add the elevation to the calculation of the distance --- contrib/calcDistance.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua index 807e23a..1c76c72 100644 --- a/contrib/calcDistance.lua +++ b/contrib/calcDistance.lua @@ -1,6 +1,6 @@ --[[ This file is part of darktable, - Copyright 2014 by Tobias Jakobs. + Copyright 2014-2016 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 @@ -26,7 +26,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1},{3,0,0}) +dt.configuration.check_version(...,{3,0,0}) local function calcDistance() local sel_images = dt.gui.selection() @@ -71,6 +71,11 @@ local function calcDistance() local angle = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)); local distance = earthRadius * angle; -- Distance in km + -- Add the elevation to the calculation + local elevation = 0; + elevation = math.abs(ele1 - ele2) / 1000; --in km + distance = math.sqrt(math.pow(elevation,2) + math.pow(distance,2) ); + dt.print(distance.." km") From fc7a25ca4d56bcc4047c24c2b29cadd311832ef5 Mon Sep 17 00:00:00 2001 From: Tobias Ellinghaus Date: Thu, 7 Jan 2016 11:23:34 +0100 Subject: [PATCH 10/67] Mark most official scripts as compatible with dt2 --- official/check_for_updates.lua | 2 +- official/delete_long_tags.lua | 2 +- official/generate_image_txt.lua | 4 ++-- official/hello_world.lua | 2 +- official/image_path_in_ui.lua | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/official/check_for_updates.lua b/official/check_for_updates.lua index 659bc28..d102e73 100644 --- a/official/check_for_updates.lua +++ b/official/check_for_updates.lua @@ -31,7 +31,7 @@ local dt = require "darktable" local https = require "ssl.https" local cjson = require "cjson" -dt.configuration.check_version(...,{2,0,0}) +dt.configuration.check_version(...,{2,0,0},{3,0,0}) -- compare two version strings of the form "major.minor.patch" -- returns -1, 0, 1 if the first version is smaller, equal, greater than the second version, diff --git a/official/delete_long_tags.lua b/official/delete_long_tags.lua index 2986f86..921a438 100644 --- a/official/delete_long_tags.lua +++ b/official/delete_long_tags.lua @@ -29,7 +29,7 @@ all tags longer than the given length will be automatically deleted at every res ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,0}) +dt.configuration.check_version(...,{2,0,0},{3,0,0}) dt.preferences.register("delete_long_tags", "length", "integer", "maximum length of tags to keep", diff --git a/official/generate_image_txt.lua b/official/generate_image_txt.lua index 7d8b697..416a8ce 100644 --- a/official/generate_image_txt.lua +++ b/official/generate_image_txt.lua @@ -31,12 +31,12 @@ USAGE -- TODO: -- * enable showing of the txt file (plugins/lighttable/draw_custom_metadata) if this script is enabled --- * maybe allow a lua command returning text instead of a command line call ? both ? +-- * maybe allow a lua command returning text instead of a command line call? both? -- * make filenames with double quotes (") work local dt = require "darktable" require "darktable.debug" -dt.configuration.check_version(...,{2,1,0}) +dt.configuration.check_version(...,{2,1,0},{3,0,0}) dt.preferences.register("generate_image_txt", "enabled", diff --git a/official/hello_world.lua b/official/hello_world.lua index e9028fb..c2997ac 100644 --- a/official/hello_world.lua +++ b/official/hello_world.lua @@ -27,7 +27,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,0}) +dt.configuration.check_version(...,{2,0,0},{3,0,0}) dt.print("hello, world") diff --git a/official/image_path_in_ui.lua b/official/image_path_in_ui.lua index ba93d2d..77b1f9f 100644 --- a/official/image_path_in_ui.lua +++ b/official/image_path_in_ui.lua @@ -29,7 +29,7 @@ This plugin will add a widget at the bottom of the left column in lighttable mod ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,0}) +dt.configuration.check_version(...,{2,0,0},{3,0,0}) local main_label = dt.new_widget("label"){selectable = true, ellipsize = "middle", halign = "start"} From 29c522484c60fd4072385896510f8e77c375823a Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Thu, 7 Jan 2016 22:01:51 +0100 Subject: [PATCH 11/67] gettextExample.lua with po and mo files --- contrib/de_DE/LC_MESSAGES/gettextExample.mo | Bin 0 -> 596 bytes contrib/de_DE/LC_MESSAGES/gettextExample.po | 20 ++++++++ contrib/gettextExample.lua | 51 ++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 contrib/de_DE/LC_MESSAGES/gettextExample.mo create mode 100644 contrib/de_DE/LC_MESSAGES/gettextExample.po create mode 100644 contrib/gettextExample.lua diff --git a/contrib/de_DE/LC_MESSAGES/gettextExample.mo b/contrib/de_DE/LC_MESSAGES/gettextExample.mo new file mode 100644 index 0000000000000000000000000000000000000000..d0ec975e6f221cb53e8f50151df7a29177c861b0 GIT binary patch literal 596 zcmZvZ&u-K(5XJ+7OW@QqhuIs5b(&-mteh^YT3WWS6#>GZ6VhxlWL>=W%J#POL3lmx zyakgiZ7z)TljqaS*q`m+d-r}t9Cw*V%$T{)957v!%tPiq^XEntU#!#3C@P)3pgM@NMtmmcl{FF;TZEQEpr4^4AL8;|C5|0o;Hr3qfh6Q<_FSZy zNMCR&CzGdXmZsb&KG3D=cKJ_VCMWr>Z-G9D%AxTZgLM)ryHx1m4gRo84+o)_$we;@ z+chek)OP(cUZ82W*pjFS*Ai~Egofhtv-6YT5?PYQ$JPWgeAM-ZJ$Lun-)K~(fO>__ zQ<#0KPQ`TS>nwdICr(Ul8)aGv)1?aWSMiz*xt-V2QlkQ7$uxP!m7Nqv=xKvtB_WAR zy>+O?sdZ~F!EAczXL$j;boSW5Xa?DnVwitR*H_jxexZDjH?Lnb|Gq)yMN<#Cxk* literal 0 HcmV?d00001 diff --git a/contrib/de_DE/LC_MESSAGES/gettextExample.po b/contrib/de_DE/LC_MESSAGES/gettextExample.po new file mode 100644 index 0000000..25cd06b --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/gettextExample.po @@ -0,0 +1,20 @@ +msgid "" +msgstr "" +"Project-Id-Version: Lua gettextTest\n" +"POT-Creation-Date: 2016-01-07 20:33+0100\n" +"PO-Revision-Date: 2016-01-07 21:32+0100\n" +"Last-Translator: Tobias Jakobs \n" +"Language-Team: \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.4\n" +"X-Poedit-Basepath: .\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2;ngettext:1,2;dngettext:2,3\n" +"X-Poedit-SearchPath-0: .\n" + +#: gettextExample.lua:36 +msgid "Hello World!" +msgstr "Hallo Welt!" diff --git a/contrib/gettextExample.lua b/contrib/gettextExample.lua new file mode 100644 index 0000000..7a90410 --- /dev/null +++ b/contrib/gettextExample.lua @@ -0,0 +1,51 @@ +--[[ + This file is part of darktable, + Copyright 2016 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 how translations works + +To create a .mo file run: +msgfmt -v gettextExample.po -o gettextExample.mo + +USAGE +* require this script from your main lua file (Add 'require "gettextExample"' to luarc.) +* copy the script to: .config/darktable/lua/ +* copy the gettextExample.mo to .config/darktable/lua/de_DE/LC_MESSAGES + +You need to start darktable with the Lua debug option: darktable -d lua +$LANG must set to: de_DE + +The script run on darktable startup and should output this three lines: + +LUA ERROR Hello World! +LUA ERROR Bild +LUA ERROR Hallo Welt! + +]] +local dt = require "darktable" +dt.configuration.check_version(...,{3,0,0}) + +-- Not translated Text +dt.print_error("Hello World!") + +-- Translate a string using the darktable textdomain +dt.print_error(dt.gettext.gettext("image")) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +dt.gettext.bindtextdomain("gettextExample",".config/darktable/lua/") +-- Translate a string using the specified textdomain +dt.print_error(dt.gettext.dgettext("gettextExample", 'Hello World!')) From bc1b908063ac180a0e6f2c955d241f23ccf57354 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 10 Jan 2016 22:28:53 +0100 Subject: [PATCH 12/67] Update kml_export.lua - support of image.title and image.description - support of image.elevation - don't add to many images to the kmz file --- contrib/kml_export.lua | 55 +++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index e9e1a31..ff5ab53 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -33,7 +33,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1},{3,0,0}) +dt.configuration.check_version(...,{3,0,0}) local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua -- collect the keys @@ -110,21 +110,29 @@ local function create_kml_file(storage, image_table, extra_data) -- Create the thumbnails for _,image in pairs(image_table) do - local path, filename, filetype = string.match(image, "(.-)([^\\/]-%.?([^%.\\/]*))$") - filename = string.upper(string.gsub(filename,"%.", "_")) + if ((_.longitude and _.latitude) and + (_.longitude ~= 0 and _.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + 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. + -- 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 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) + end + + -- delete the original image to not get into the kmz file + local rmCommand = "rm "..image + coroutine.yield("RUN_COMMAND", rmCommand) local pattern = "[/]?([^/]+)$" filmName = string.match(_.film.path, pattern) @@ -134,7 +142,7 @@ local function create_kml_file(storage, image_table, extra_data) exportKMZFilename = filmName..".kmz" -- Create the KML file - kml_file = "\n" + local kml_file = "\n" kml_file = kml_file.."\n" kml_file = kml_file.."\n" @@ -149,8 +157,13 @@ local function create_kml_file(storage, image_table, extra_data) (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" + if (image.title and image.title ~= "") then + kml_file = kml_file.." "..image.title.."\n" + else + kml_file = kml_file.." "..image.filename.."\n" + end + + kml_file = kml_file.." "..image.description.."\n" kml_file = kml_file.." + + +
+ + + + +]] + + file = io.open(exportDirectory.."/"..exportMapBoxHTMLFilename, "w") + file:write(mapBoxHTML_file) + file:close() + end + + file = io.open(exportDirectory.."/"..exportgeoJSONFilename, "w") + file:write(geoJSON_file) + file:close() + + dt.print("geoJSON file created in "..exportDirectory) + +-- Open the file with the standard programm + if ( dt.preferences.read("geoJSON_export","OpengeoJSONFile","bool") == true ) then + local geoJSONFileOpenCommand + geoJSONFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportgeoJSONFilename.."\"" + coroutine.yield("RUN_COMMAND", geoJSONFileOpenCommand) + end + + +end + +-- Preferences +dt.preferences.register("geoJSON_export", + "CreateMapBoxHTMLFile", + "bool", + _("geoJSON export: Create an additional HTML file"), + _("Creates a HTML file, that loads the geoJASON file. (Needs a MapBox key"), + false ) +dt.preferences.register("geoJSON_export", + "mapBoxKey", + "string", + _("geoJSON export: MapBox Key"), + _("https://www.mapbox.com/studio/account/tokens"), + '' ) +dt.preferences.register("geoJSON_export", + "OpengeoJSONFile", + "bool", + _("geoJSON export: Open geoJSON file after export"), + _("Opens the geoJSON file after the export with the standard program for geoJSON files"), + false ) + +local handle = io.popen("xdg-user-dir DESKTOP") +local result = handle:read() +handle:close() +dt.preferences.register("geoJSON_export", + "ExportDirectory", + "directory", + _("geoJSON export: Export directory"), + _("A directory that will be used to export the geoJSON files"), + result ) + +-- Register +dt.register_storage("geoJSON_export", "geoJSON Export", nil, create_geoJSON_file) From b2ee46804bdc6c2a012da6e461400c099130dd72 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 17 Mar 2016 22:33:27 +0100 Subject: [PATCH 56/67] marked vars as local, changed gettext domain --- contrib/geoJSON_export.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index 30a2adf..d19ceb9 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -40,7 +40,7 @@ dt.configuration.check_version(...,{3,0,0}) gettext.bindtextdomain("geoJSON_export",dt.configuration.config_dir.."/lua/") local function _(msgid) - return gettext.dgettext("kml_export", msgid) + return gettext.dgettext("geoJSON_export", msgid) end -- Sort a table @@ -101,10 +101,10 @@ local function create_geoJSON_file(storage, image_table, extra_data) dt.print_error("Will try to export geoJSON file now") - exportDirectory = dt.preferences.read("geoJSON_export","ExportDirectory","string") + local xportDirectory = dt.preferences.read("geoJSON_export","ExportDirectory","string") -- Creates dir if not exsists - imageFoldername = "files/" + local imageFoldername = "files/" local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername coroutine.yield("RUN_COMMAND", mkdirCommand) @@ -137,11 +137,11 @@ local function create_geoJSON_file(storage, image_table, extra_data) filmName = string.match(_.film.path, pattern) end - exportgeoJSONFilename = filmName..".geoJSON" - exportMapBoxHTMLFilename = filmName..".html" + local exportgeoJSONFilename = filmName..".geoJSON" + local exportMapBoxHTMLFilename = filmName..".html" -- Create the geoJSON file - geoJSON_file = [[ + local geoJSON_file = [[ { "type": "FeatureCollection", "features": [ @@ -265,12 +265,12 @@ local function create_geoJSON_file(storage, image_table, extra_data) ]] - file = io.open(exportDirectory.."/"..exportMapBoxHTMLFilename, "w") + local file = io.open(exportDirectory.."/"..exportMapBoxHTMLFilename, "w") file:write(mapBoxHTML_file) file:close() end - file = io.open(exportDirectory.."/"..exportgeoJSONFilename, "w") + local file = io.open(exportDirectory.."/"..exportgeoJSONFilename, "w") file:write(geoJSON_file) file:close() From ef96bfa98c1c4ecf18616cf57a2e38860a669cbb Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 17 Mar 2016 22:35:47 +0100 Subject: [PATCH 57/67] marked vars as local --- contrib/kml_export.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index 0be2627..75e1790 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -29,7 +29,8 @@ WARNING This script is only tested with Linux USAGE -* require this script from your main lua file +* require this script from your main Lua file + ]] local dt = require "darktable" @@ -101,6 +102,7 @@ local function create_kml_file(storage, image_table, extra_data) dt.print_error("Will try to export KML file now") + local imageFoldername if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then if not checkIfBinExists("zip") then return @@ -234,7 +236,7 @@ local function create_kml_file(storage, image_table, extra_data) kml_file = kml_file.."
\n" kml_file = kml_file.."
" - file = io.open(exportDirectory.."/"..exportKMLFilename, "w") + local file = io.open(exportDirectory.."/"..exportKMLFilename, "w") file:write(kml_file) file:close() @@ -270,7 +272,7 @@ 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"), + _("Opens the KML file after the export with the standard program for KML files"), false ) local handle = io.popen("xdg-user-dir DESKTOP") From f64892d0103cb7b5c4ec5a50b80ba5a689ba9e7c Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 20 Mar 2016 21:50:25 +0100 Subject: [PATCH 58/67] concertToThumbCommand -> convertToThumbCommand --- contrib/geoJSON_export.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index d19ceb9..cbac2a3 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -123,9 +123,9 @@ local function create_geoJSON_file(storage, image_table, extra_data) -- 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" + local convertToThumbCommand = "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) + coroutine.yield("RUN_COMMAND", convertToThumbCommand) local concertCommand = "convert -size 438x438 "..image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" coroutine.yield("RUN_COMMAND", concertCommand) end From 2a2bb7199e46b70908be3698be24cb2ca09e4551 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 20 Mar 2016 21:51:26 +0100 Subject: [PATCH 59/67] concertToThumbCommand -> convertToThumbCommand --- contrib/kml_export.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index 75e1790..5cf24d7 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -134,9 +134,9 @@ local function create_kml_file(storage, image_table, extra_data) -- 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" + local convertToThumbCommand = "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) + coroutine.yield("RUN_COMMAND", convertToThumbCommand) local concertCommand = "convert -size 438x438 "..image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" coroutine.yield("RUN_COMMAND", concertCommand) end From 027a24983723122f96cfbb0783c359fcc48a2ccd Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 20 Mar 2016 22:03:41 +0100 Subject: [PATCH 60/67] _ -> exported_image --- contrib/geoJSON_export.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index cbac2a3..af4836d 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -109,9 +109,9 @@ local function create_geoJSON_file(storage, image_table, extra_data) coroutine.yield("RUN_COMMAND", mkdirCommand) -- Create the thumbnails - for _,image in pairs(image_table) do - if ((_.longitude and _.latitude) and - (_.longitude ~= 0 and _.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + for exported_image,image in pairs(image_table) do + if ((exported_image.longitude and exported_image.latitude) and + (exported_image.longitude ~= 0 and exported_image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data ) then local path, filename, filetype = string.match(image, "(.-)([^\\/]-%.?([^%.\\/]*))$") filename = string.upper(string.gsub(filename,"%.", "_")) @@ -134,7 +134,7 @@ local function create_geoJSON_file(storage, image_table, extra_data) os.remove(image) local pattern = "[/]?([^/]+)$" - filmName = string.match(_.film.path, pattern) + filmName = string.match(exported_image.film.path, pattern) end local exportgeoJSONFilename = filmName..".geoJSON" @@ -147,7 +147,7 @@ local function create_geoJSON_file(storage, image_table, extra_data) "features": [ ]] - for image,_ in pairs(image_table) do + for image,exported_image in pairs(image_table) do filename = string.upper(string.gsub(image.filename,"%.", "_")) if ((image.longitude and image.latitude) and From fb171a459eb00cb0a10e6ef263e7b8a5f0ce5ce4 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 20 Mar 2016 22:21:40 +0100 Subject: [PATCH 61/67] Update geoJSON_export.lua --- contrib/geoJSON_export.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index af4836d..aca16a5 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -147,11 +147,11 @@ local function create_geoJSON_file(storage, image_table, extra_data) "features": [ ]] - for image,exported_image in pairs(image_table) do - filename = string.upper(string.gsub(image.filename,"%.", "_")) + for exported_image,image in pairs(image_table) do + filename = string.upper(string.gsub(exported_image.filename,"%.", "_")) - if ((image.longitude and image.latitude) and - (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + if ((exported_image.longitude and exported_image.latitude) and + (exported_image.longitude ~= 0 and exported_image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data ) then geoJSON_file = geoJSON_file.. [[ { @@ -159,12 +159,12 @@ local function create_geoJSON_file(storage, image_table, extra_data) "geometry": { "type": "Point", ]] - geoJSON_file = geoJSON_file.." \"coordinates\": ["..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".").."]\n" + geoJSON_file = geoJSON_file.." \"coordinates\": ["..string.gsub(tostring(exported_image.longitude),",", ".")..","..string.gsub(tostring(exported_image.latitude),",", ".").."]\n" geoJSON_file = geoJSON_file.. [[ }, "properties": { - "title": "]]..image.title..[[", - "description": "]]..image.description..[[", + "title": "]]..exported_image.title..[[", + "description": "]]..exported_image.description..[[", "image": "]]..imageFoldername..filename..[[.jpg", "icon": { "iconUrl": "]]..imageFoldername.."thumb_"..filename..[[.jpg", From ebda3865dc996a6bd21a80e51d809fb40429b9b4 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 20 Mar 2016 22:36:58 +0100 Subject: [PATCH 62/67] Update geoJSON_export.lua --- contrib/geoJSON_export.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index aca16a5..c5fc0b7 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -109,9 +109,9 @@ local function create_geoJSON_file(storage, image_table, extra_data) coroutine.yield("RUN_COMMAND", mkdirCommand) -- Create the thumbnails - for exported_image,image in pairs(image_table) do - if ((exported_image.longitude and exported_image.latitude) and - (exported_image.longitude ~= 0 and exported_image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + for image,exported_image in pairs(image_table) do + 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 local path, filename, filetype = string.match(image, "(.-)([^\\/]-%.?([^%.\\/]*))$") filename = string.upper(string.gsub(filename,"%.", "_")) @@ -123,10 +123,10 @@ local function create_geoJSON_file(storage, image_table, extra_data) -- 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 convertToThumbCommand = "convert -size 96x96 "..image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg" + local convertToThumbCommand = "convert -size 96x96 "..exported_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", convertToThumbCommand) - local concertCommand = "convert -size 438x438 "..image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" + local concertCommand = "convert -size 438x438 "..exported_image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" coroutine.yield("RUN_COMMAND", concertCommand) end @@ -134,7 +134,7 @@ local function create_geoJSON_file(storage, image_table, extra_data) os.remove(image) local pattern = "[/]?([^/]+)$" - filmName = string.match(exported_image.film.path, pattern) + filmName = string.match(image.film.path, pattern) end local exportgeoJSONFilename = filmName..".geoJSON" @@ -147,11 +147,11 @@ local function create_geoJSON_file(storage, image_table, extra_data) "features": [ ]] - for exported_image,image in pairs(image_table) do - filename = string.upper(string.gsub(exported_image.filename,"%.", "_")) + for image,exported_image in pairs(image_table) do + filename = string.upper(string.gsub(image.filename,"%.", "_")) - if ((exported_image.longitude and exported_image.latitude) and - (exported_image.longitude ~= 0 and exported_image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + 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 geoJSON_file = geoJSON_file.. [[ { @@ -159,12 +159,12 @@ local function create_geoJSON_file(storage, image_table, extra_data) "geometry": { "type": "Point", ]] - geoJSON_file = geoJSON_file.." \"coordinates\": ["..string.gsub(tostring(exported_image.longitude),",", ".")..","..string.gsub(tostring(exported_image.latitude),",", ".").."]\n" + geoJSON_file = geoJSON_file.." \"coordinates\": ["..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".").."]\n" geoJSON_file = geoJSON_file.. [[ }, "properties": { - "title": "]]..exported_image.title..[[", - "description": "]]..exported_image.description..[[", + "title": "]]..image.title..[[", + "description": "]]..image.description..[[", "image": "]]..imageFoldername..filename..[[.jpg", "icon": { "iconUrl": "]]..imageFoldername.."thumb_"..filename..[[.jpg", From 17a8c4f3d5eaa81b2c96f96e58c5add2b32cc664 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 20 Mar 2016 22:59:18 +0100 Subject: [PATCH 63/67] naming changes _ -> exported_image --- contrib/kml_export.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index 5cf24d7..f69efed 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -120,11 +120,11 @@ local function create_kml_file(storage, image_table, extra_data) -- Create the thumbnails - for _,image in pairs(image_table) do - if ((_.longitude and _.latitude) and - (_.longitude ~= 0 and _.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + for image,exported_image in pairs(image_table) do + 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 - local path, filename, filetype = string.match(image, "(.-)([^\\/]-%.?([^%.\\/]*))$") + local path, filename, filetype = string.match(exported_image, "(.-)([^\\/]-%.?([^%.\\/]*))$") filename = string.upper(string.gsub(filename,"%.", "_")) -- convert -size 92x92 filename.jpg -resize 92x92 +profile "*" thumbnail.jpg @@ -134,18 +134,18 @@ local function create_kml_file(storage, image_table, extra_data) -- 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 convertToThumbCommand = "convert -size 96x96 "..image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg" + local convertToThumbCommand = "convert -size 96x96 "..exported_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", convertToThumbCommand) - local concertCommand = "convert -size 438x438 "..image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" + local concertCommand = "convert -size 438x438 "..exported_image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" coroutine.yield("RUN_COMMAND", concertCommand) end -- delete the original image to not get into the kmz file - os.remove(image) + os.remove(exported_image) local pattern = "[/]?([^/]+)$" - filmName = string.match(_.film.path, pattern) + filmName = string.match(image.film.path, pattern) end exportKMLFilename = filmName..".kml" @@ -160,7 +160,7 @@ local function create_kml_file(storage, image_table, extra_data) kml_file = kml_file..""..filmName.."\n" kml_file = kml_file.." Exported from darktable\n" - for image,_ in pairs(image_table) do + for image,exported_image in pairs(image_table) do filename = string.upper(string.gsub(image.filename,"%.", "_")) if ((image.longitude and image.latitude) and @@ -216,7 +216,7 @@ local function create_kml_file(storage, image_table, extra_data) 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 + for image,exported_image in spairs(image_table, function(t,a,b) return t[b] < t[a] end) do 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 From 5006c9d6ea70001ee8427b0b959ed57add3fcb1f Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 22 Mar 2016 22:34:53 +0100 Subject: [PATCH 64/67] Added missing elevation vars, improved short distance view --- contrib/calcDistance.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua index ea1c4b4..b4ce9a1 100644 --- a/contrib/calcDistance.lua +++ b/contrib/calcDistance.lua @@ -43,6 +43,9 @@ local function calcDistance() local lon1 = 0; local lat2 = 0; local lon2 = 0; + local ele1 = 0; + local ele2 = 0; + local i = 0; local sel_images = dt.gui.selection() @@ -57,10 +60,12 @@ local function calcDistance() if (i == 1) then lat1 = image.latitude; lon1 = image.longitude; + ele1 = image.elevation; end lat2 = image.latitude; lon2 = image.longitude; + ele2 = image.elevation; end end @@ -84,7 +89,15 @@ local function calcDistance() elevation = math.abs(ele1 - ele2) / 1000; --in km distance = math.sqrt(math.pow(elevation,2) + math.pow(distance,2) ); - dt.print(distance.." km") + local distanceUnit + if (distance < 1) then + distance = distance * 1000 + distanceUnit = "m" + else + distanceUnit = "km" + end + dt.print(string.format("Distance: %.2f %s", distance, distanceUnit)) + end From 0c9d4a5de4cb94032e91d20848426376ff0954b4 Mon Sep 17 00:00:00 2001 From: supertobi Date: Wed, 23 Mar 2016 10:32:16 +0100 Subject: [PATCH 65/67] added tooltip to new_widget("entry") --- examples/moduleExample.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/moduleExample.lua b/examples/moduleExample.lua index 363ae76..f484dff 100644 --- a/examples/moduleExample.lua +++ b/examples/moduleExample.lua @@ -37,7 +37,7 @@ dt.configuration.check_version(...,{3,0,0}) -- add a new lib local check_button = dt.new_widget("check_button"){label = "MyCheck_button", value = true} local combobox = dt.new_widget("combobox"){label = "MyCombobox", value = 2, "8", "16", "32"} -local entry = dt.new_widget("entry"){text = "test", placeholder = "placeholder"} +local entry = dt.new_widget("entry"){text = "test", placeholder = "placeholder", tooltip = "tooltip"} local file_chooser_button = dt.new_widget("file_chooser_button"){title = "MyFile_chooser_button"} local label = dt.new_widget("label") label.label = "MyLabel" -- This is an alternative way to the "{}" syntax to set a property From f6e2037a1bce2fe177835d8a318f9598a91f2e82 Mon Sep 17 00:00:00 2001 From: Tobias Ellinghaus Date: Tue, 29 Mar 2016 19:52:31 +0200 Subject: [PATCH 66/67] Fix formatting of copyright header --- official/enfuse.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/official/enfuse.lua b/official/enfuse.lua index 32a835b..3a0ac59 100644 --- a/official/enfuse.lua +++ b/official/enfuse.lua @@ -8,7 +8,7 @@ (at your option) any later version. darktable is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of + 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. From 6c4f9b2c03437e0d00ae60edd9f945b186077968 Mon Sep 17 00:00:00 2001 From: Tobias Ellinghaus Date: Tue, 29 Mar 2016 20:11:19 +0200 Subject: [PATCH 67/67] Add script to copy & paste metadata between images This not only takes care of tags (we already have a script for that in contrib) but also color labels, rating and the things from the metadata module. --- official/copy_paste_metadata.lua | 128 +++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 official/copy_paste_metadata.lua diff --git a/official/copy_paste_metadata.lua b/official/copy_paste_metadata.lua new file mode 100644 index 0000000..10281ca --- /dev/null +++ b/official/copy_paste_metadata.lua @@ -0,0 +1,128 @@ +--[[ + This file is part of darktable, + copyright (c) 2016 Tobias Ellinghaus + + darktable 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. + + darktable 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 darktable. If not, see . +]] +--[[ +ADD SUPPORT FOR COPYING METADATA+RATING+COLOR LABELS+TAGS BETWEEN IMAGES +This script adds keyboard shortcuts and buttons to copy/paste metadata between images. + +USAGE + * require this script from your main lua file + * it adds buttons to the selected images module + * it adds two keyboard shortcuts +]] + +local dt = require "darktable" + +dt.configuration.check_version(...,{3,0,0}) + +-- set this to "false" if you don't want to overwrite metadata fields +-- (title, description, creator, publisher and rights) that are already set +local overwrite = true + +local have_data = false +local rating = 1 +local red = false +local green = false +local yellow = false +local blue = false +local purple = false +local title = "" +local description = "" +local creator = "" +local publisher = "" +local rights = "" +local tags = {} + +local function copy(image) + if not image then + have_data = false + else + have_data = true + rating = image.rating + red = image.red + green = image.green + yellow = image.yellow + blue = image.blue + purple = image.purple + title = image.title + description = image.description + creator = image.creator + publisher = image.publisher + rights = image.rights + tags = {} + for _, tag in ipairs(image:get_tags()) do + if not (string.sub(tag.name, 1, string.len("darktable|")) == "darktable|") then + table.insert(tags, tag) + end + end + end +end + +local function paste(images) + if have_data then + for _, image in ipairs(images) do + image.rating = rating + image.red = red + image.green = green + image.yellow = yellow + image.blue = blue + image.purple = purple + if image.title == "" or overwrite then + image.title = title + end + if image.description == "" or overwrite then + image.description = description + end + if image.creator == "" or overwrite then + image.creator = creator + end + if image.publisher == "" or overwrite then + image.publisher = publisher + end + if image.rights == "" or overwrite then + image.rights = rights + end + for _, tag in ipairs(tags) do + image:attach_tag(tag) + end + end + end +end + +dt.gui.libs.image.register_action( + "copy metadata", + function(event, images) copy(images[1]) end, + "copy metadata of the first selected image" +) + +dt.gui.libs.image.register_action( + "paste metadata", + function(event, images) paste(images) end, + "paste metadata to the selected images" +) + +dt.register_event( + "shortcut", + function(event, shortcut) copy(dt.gui.action_images[1]) end, + "copy metadata" +) + +dt.register_event( + "shortcut", + function(event, shortcut) paste(dt.gui.action_images) end, + "paste metadata" +)