From 38bda12c4bd53f0d4be35a144b5b61df8e452bda Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 4 Jan 2016 22:59:18 +0100 Subject: [PATCH 1/9] Update calcDistance.lua Tested with darktable 2.0 --- contrib/calcDistance.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua index c21dd69..807e23a 100644 --- a/contrib/calcDistance.lua +++ b/contrib/calcDistance.lua @@ -26,7 +26,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) +dt.configuration.check_version(...,{2,0,1},{3,0,0}) local function calcDistance() local sel_images = dt.gui.selection() From 0b3b095eac78e8653c72ec95b33fd2960baeb34e Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 4 Jan 2016 23:00:33 +0100 Subject: [PATCH 2/9] Update kml_export.lua Tested with darktable 2.0 --- 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 da3c2d4..e9e1a31 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}) +dt.configuration.check_version(...,{2,0,1},{3,0,0}) local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua -- collect the keys From 15cd18a5c446832bd4001211e9e0f5b37c57e0d0 Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 4 Jan 2016 23:02:01 +0100 Subject: [PATCH 3/9] Update preferenceExamples.lua Tested with darktable 2.0 --- contrib/preferenceExamples.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/preferenceExamples.lua b/contrib/preferenceExamples.lua index 34117e6..9317aab 100644 --- a/contrib/preferenceExamples.lua +++ b/contrib/preferenceExamples.lua @@ -22,7 +22,7 @@ USAGE * require this script from your main lua file ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) +dt.configuration.check_version(...,{2,0,1},{3,0,0}) 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 From cba5c65608a1f601627d905d6af65a25c68e4d89 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 5 Jan 2016 22:05:18 +0100 Subject: [PATCH 4/9] 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 5/9] 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 98a41444035efcdd78ba4545e228297cf5165df3 Mon Sep 17 00:00:00 2001 From: wpferguson Date: Wed, 6 Jan 2016 10:51:56 -0500 Subject: [PATCH 6/9] Update selection_to_pdf.lua Added API version 3.0.0 for compatibility with Darktable 2.0. Tested with Darktable 2.0. --- official/selection_to_pdf.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/official/selection_to_pdf.lua b/official/selection_to_pdf.lua index 2930e55..8444e8e 100644 --- a/official/selection_to_pdf.lua +++ b/official/selection_to_pdf.lua @@ -31,7 +31,7 @@ This plugin will add a new exporter that will allow you to generate the pdf file ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,0}) +dt.configuration.check_version(...,{2,0,0},{3,0,0}) dt.preferences.register ("selection_to_pdf","Open with","string", From 1d3a44a157a570abd4d474b51d41fd5dd47b1c81 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 7 Jan 2016 09:08:35 +0100 Subject: [PATCH 7/9] 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 8/9] 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 bc1b908063ac180a0e6f2c955d241f23ccf57354 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 10 Jan 2016 22:28:53 +0100 Subject: [PATCH 9/9] 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.."