diff --git a/contrib/autostyle.lua b/contrib/autostyle.lua index 83ebb84..c8dafaf 100644 --- a/contrib/autostyle.lua +++ b/contrib/autostyle.lua @@ -41,7 +41,7 @@ local darktable = require "darktable" local autostyle_apply_one_image,autostyle_apply_one_image_event,autostyle_apply,exiftool_attribute,capture -- Tested it with darktable 1.6.1 and darktable git from 2014-01-25 -darktable.configuration.check_version(...,{2,0,2},{2,1,0}) +darktable.configuration.check_version(...,{2,0,2},{2,1,0},{3,0,0}) -- Receive the event triggered function autostyle_apply_one_image_event(event,image) diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua index 807e23a..b4ce9a1 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,15 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1},{3,0,0}) +local gettext = dt.gettext +dt.configuration.check_version(...,{3,0,0}) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +gettext.bindtextdomain("calcDistance",dt.configuration.config_dir.."/lua/") + +local function _(msgid) + return gettext.dgettext("calcDistance", msgid) +end local function calcDistance() local sel_images = dt.gui.selection() @@ -35,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() @@ -49,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 @@ -71,10 +84,23 @@ 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.." 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) ); + + 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 -- Register -dt.register_event("shortcut",calcDistance,"Calculate the distance from latitude and longitude in km") +dt.register_event("shortcut",calcDistance,_("Calculate the distance from latitude and longitude in km")) diff --git a/contrib/cr2hdr.lua b/contrib/cr2hdr.lua index e6bc214..d57e912 100644 --- a/contrib/cr2hdr.lua +++ b/contrib/cr2hdr.lua @@ -34,8 +34,8 @@ USAGE local darktable = require "darktable" --- Tested with darktable 1.6.2 -darktable.configuration.check_version(...,{2,0,2}) +-- Tested with darktable 2.0.1 +darktable.configuration.check_version(...,{2,0,0},{3,0,0}) local queue = {} local processed_files = {} diff --git a/contrib/de_DE/LC_MESSAGES/calcDistance.po b/contrib/de_DE/LC_MESSAGES/calcDistance.po new file mode 100644 index 0000000..b493110 --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/calcDistance.po @@ -0,0 +1,22 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-31 22:57+0100\n" +"PO-Revision-Date: 2016-01-31 23:02+0100\n" +"Language: de_DE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: Tobias Jakobs \n" +"Language-Team: \n" +"X-Generator: Poedit 1.8.4\n" + +#: calcDistance.lua:93 +msgid "Calculate the distance from latitude and longitude in km" +msgstr "Errechne die Entfernung mit Hilfe des Längen- und Breitengrads in km" diff --git a/contrib/de_DE/LC_MESSAGES/geo_uri.po b/contrib/de_DE/LC_MESSAGES/geo_uri.po new file mode 100644 index 0000000..e778fa1 --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/geo_uri.po @@ -0,0 +1,30 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-31 22:58+0100\n" +"PO-Revision-Date: 2016-01-31 23:13+0100\n" +"Language: de_DE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: Tobias Jakobs \n" +"Language-Team: \n" +"X-Generator: Poedit 1.8.4\n" + +#: geo_uri.lua:55 +msgid "gnome-maps not found" +msgstr "gnome-maps wurde nicht gefunden" + +#: geo_uri.lua:81 +msgid "Command failed ..." +msgstr "Aufruf fehlgeschlagen ..." + +#: geo_uri.lua:88 +msgid "Open Location in Gnome Maps" +msgstr "Öffnet den Ort in Gnome Maps" diff --git a/contrib/de_DE/LC_MESSAGES/gps_select.po b/contrib/de_DE/LC_MESSAGES/gps_select.po new file mode 100644 index 0000000..1b343c0 --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/gps_select.po @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-31 22:58+0100\n" +"PO-Revision-Date: 2016-01-31 23:05+0100\n" +"Language: de_DE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: Tobias Jakobs \n" +"Language-Team: \n" +"X-Generator: Poedit 1.8.4\n" + +#: gps_select.lua:59 +msgid "Select all images with GPS information" +msgstr "Markiert alle Bilder mit GPS-Informationen" + +#: gps_select.lua:60 +msgid "Select all images without GPS information" +msgstr "Markiert alle Bilder ohne GPS-Informationen" diff --git a/contrib/de_DE/LC_MESSAGES/hugin.po b/contrib/de_DE/LC_MESSAGES/hugin.po new file mode 100644 index 0000000..bdc8cde --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/hugin.po @@ -0,0 +1,42 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-31 22:59+0100\n" +"PO-Revision-Date: 2016-01-31 23:09+0100\n" +"Language: de_DE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: Tobias Jakobs \n" +"Language-Team: \n" +"X-Generator: Poedit 1.8.4\n" + +#: hugin.lua:73 +msgid "hugin not found" +msgstr "Hugin wurde nicht gefunden" + +#: hugin.lua:97 +msgid "Will try to stitch now" +msgstr "Versuche Bilder zusammenzufügen" + +#: hugin.lua:102 +msgid "Creating pto file" +msgstr "Erzeuge pto Datei" + +#: hugin.lua:105 +msgid "Running Assistent" +msgstr "Starte den Assistenten" + +#: hugin.lua:118 +msgid "Command hugin failed ..." +msgstr "Aufruf von hugin fehlgeschlagen ..." + +#: hugin.lua:124 +msgid "Hugin Panorama" +msgstr "Hugin Panorama" diff --git a/contrib/de_DE/LC_MESSAGES/kml_export.po b/contrib/de_DE/LC_MESSAGES/kml_export.po new file mode 100644 index 0000000..9a1bf23 --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/kml_export.po @@ -0,0 +1,46 @@ +msgid "" +msgstr "" +"Project-Id-Version: Lua gettextTest\n" +"POT-Creation-Date: 2016-01-22 15:33+0100\n" +"PO-Revision-Date: 2016-01-22 23:28+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;t" plural=(n != 1);\n" +"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2;ngettext:1,2;dngettext:2,3\n" +"X-Poedit-SearchPath-0: .\n" + +msgid "KML/KMZ Export" +msgstr "KML/KMZ Expor + +msgid "Export Image %i/%i" +msgstr "Exportiere Bild %i/%i" + +msgid "KML export: Open KML/KMZ file after export" +msgstr "KML export: KML/KMZ-Datei nach dem exportieren öffnen" + +msgid "Opens the KML file after the export with the standard programm for KML files" +msgstr "Öffnet die KML-Datei mit dem Standardprogram für KML-Dateien" + +msgid "KML export: Export directory" +msgstr "KML export: Export-Verzeichnis" + +msgid "A directory that will be used to export the KML/KMZ files" +msgstr "Verzeichnis in das die KML/KMZ-Dateien exportiert werden" + +msgid "KML export: Connect images with path" +msgstr "KML export: Bilder mit einer Linie verbinden" + +msgid "connect all images with a path" +msgstr "Verbinde alle Bilder mit einer Linie" + +msgid "KML export: Create KMZ file" +msgstr "KML export: KMZ-Datei erstellen" + +msgid "Compress all imeges to one KMZ file" +msgstr "Alle Bilder in einer KMZ-Datei komprimieren" diff --git a/contrib/de_DE/LC_MESSAGES/slideshowMusic.po b/contrib/de_DE/LC_MESSAGES/slideshowMusic.po new file mode 100644 index 0000000..6919bba --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/slideshowMusic.po @@ -0,0 +1,30 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-31 22:59+0100\n" +"PO-Revision-Date: 2016-01-31 23:13+0100\n" +"Language: de_DE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: Tobias Jakobs \n" +"Language-Team: \n" +"X-Generator: Poedit 1.8.4\n" + +#: slideshowMusic.lua:80 +msgid "Slideshow background music file" +msgstr "Diashow Hintergrundmusik-Datei" + +#: slideshowMusic.lua:84 +msgid "Play slideshow background music" +msgstr "Diashow Hintergrundmusik abspielen" + +#: slideshowMusic.lua:85 +msgid "Plays music with rhythmbox if a slideshow starts" +msgstr "Musik mit Rhythmbox abspielen, wenn die Diashow beginnt" diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua new file mode 100644 index 0000000..c5fc0b7 --- /dev/null +++ b/contrib/geoJSON_export.lua @@ -0,0 +1,320 @@ +--[[ + 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 geoJSON export script + +ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT +* mkdir +* convert (ImageMagick) +* xdg-open +* xdg-user-dir + +WARNING +This script is only tested with Linux + +USAGE +* require this script from your main Lua file + +]] + +local dt = require "darktable" +local gettext = dt.gettext +dt.configuration.check_version(...,{3,0,0}) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +gettext.bindtextdomain("geoJSON_export",dt.configuration.config_dir.."/lua/") + +local function _(msgid) + return gettext.dgettext("geoJSON_export", msgid) +end + +-- Sort a table +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 + + -- 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(string.format(_("Export Image %i/%i"), number, 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_geoJSON_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 geoJSON file now") + + local xportDirectory = dt.preferences.read("geoJSON_export","ExportDirectory","string") + + -- Creates dir if not exsists + local imageFoldername = "files/" + local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername + coroutine.yield("RUN_COMMAND", mkdirCommand) + + -- Create the thumbnails + 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,"%.", "_")) + + -- 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 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 "..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) + + local pattern = "[/]?([^/]+)$" + filmName = string.match(image.film.path, pattern) + end + + local exportgeoJSONFilename = filmName..".geoJSON" + local exportMapBoxHTMLFilename = filmName..".html" + + -- Create the geoJSON file + local geoJSON_file = [[ +{ + "type": "FeatureCollection", + "features": [ +]] + + for image,exported_image in pairs(image_table) do + filename = string.upper(string.gsub(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 + ) then + geoJSON_file = geoJSON_file.. +[[ { + "type": "Feature", + "geometry": { + "type": "Point", +]] + geoJSON_file = geoJSON_file.." \"coordinates\": ["..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".").."]\n" + geoJSON_file = geoJSON_file.. +[[ }, + "properties": { + "title": "]]..image.title..[[", + "description": "]]..image.description..[[", + "image": "]]..imageFoldername..filename..[[.jpg", + "icon": { + "iconUrl": "]]..imageFoldername.."thumb_"..filename..[[.jpg", + "iconSize": [96, 65], + "iconAnchor": [48, 32], + "popupAnchor": [0, -32], + "className": "dot" + } + } + } + ,]] + end + end + + geoJSON_file = geoJSON_file:sub(0,geoJSON_file:len()-1) + geoJSON_file = geoJSON_file.. +[[ +] +} +]] + + + --HTML + if ( dt.preferences.read("geoJSON_export","CreateMapBoxHTMLFile","bool") == true ) then + local mapBoxKey = dt.preferences.read("geoJSON_export","mapBoxKey","string") + local mapBoxHTML_file = [[ + + + + + 2014-05-31 Rieselfelder + + + + + +
+ + + + +]] + + local file = io.open(exportDirectory.."/"..exportMapBoxHTMLFilename, "w") + file:write(mapBoxHTML_file) + file:close() + end + + local 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) diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua new file mode 100644 index 0000000..04ad553 --- /dev/null +++ b/contrib/geo_uri.lua @@ -0,0 +1,88 @@ +--[[ + 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 open a geo uri in gnome-maps + +ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT +* gnome-maps >= 3.20 + +USAGE +* require this script from your main lua file +* register a shortcut +]] + +local dt = require "darktable" +local gettext = dt.gettext +dt.configuration.check_version(...,{3,0,0}) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +gettext.bindtextdomain("geo_uri",dt.configuration.config_dir.."/lua/") + +local function _(msgid) + return gettext.dgettext("geo_uri", msgid) +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 openLocationInGnomeMaps() + if not checkIfBinExists("gnome-maps") then + dt.print_error(_("gnome-maps not found")) + return + end + + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local i = 0; + + -- 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 + lat1 = image.latitude; + lon1 = image.longitude; + break + end + end + + local startCommand + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" + 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")) diff --git a/contrib/gps_select.lua b/contrib/gps_select.lua index 14fbf75..b1c47ca 100644 --- a/contrib/gps_select.lua +++ b/contrib/gps_select.lua @@ -24,7 +24,16 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) +local gettext = dt.gettext +dt.configuration.check_version(...,{2,0,1},{3,0,0}) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +gettext.bindtextdomain("gps_select",dt.configuration.config_dir.."/lua/") + +local function _(msgid) + return gettext.dgettext("gps_select", msgid) +end + table = require "table" local function selectWithGPS() @@ -47,5 +56,5 @@ local function selectWithoutGPS() 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") +dt.register_event("shortcut", selectWithGPS, _("Select all images with GPS information")) +dt.register_event("shortcut", selectWithoutGPS, _("Select all images without GPS information")) diff --git a/contrib/hugin.lua b/contrib/hugin.lua index 819e5b2..d6f6622 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -34,9 +34,17 @@ This plugin will add a new storage option and calls hugin after export. ]] local dt = require "darktable" +local gettext = dt.gettext --- 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}) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +gettext.bindtextdomain("hugin",dt.configuration.config_dir.."/lua/") + +local function _(msgid) + return gettext.dgettext("hugin", msgid) +end local function checkIfBinExists(bin) local handle = io.popen("which "..bin) @@ -62,7 +70,7 @@ end local function create_panorama(storage, image_table, extra_data) --finalize if not checkIfBinExists("hugin") then - darktable.print_error("hugin not found") + dt.print_error(_("hugin not found")) return end @@ -86,15 +94,15 @@ local function create_panorama(storage, image_table, extra_data) --finalize img_list = img_list ..v.. " " end - dt.print("Will try to stitch now") + dt.print(_("Will try to stitch now")) local huginStartCommand if (hugin_executor) then huginStartCommand = "pto_gen "..img_list.." -o "..dt.configuration.tmp_dir.."/project.pto" - dt.print("Creating pto file") + dt.print(_("Creating pto file")) coroutine.yield("RUN_COMMAND", huginStartCommand) - dt.print("Running Assistent") + dt.print(_("Running Assistent")) huginStartCommand = "hugin_executor --assistant "..dt.configuration.tmp_dir.."/project.pto" coroutine.yield("RUN_COMMAND", huginStartCommand) @@ -107,13 +115,13 @@ local function create_panorama(storage, image_table, extra_data) --finalize if coroutine.yield("RUN_COMMAND", huginStartCommand) then - dt.print("Command hugin failed ...") + dt.print(_("Command hugin failed ...")) end end -- Register -dt.register_storage("module_hugin", "Hugin Panorama", show_status, create_panorama) +dt.register_storage("module_hugin", _("Hugin Panorama"), show_status, create_panorama) -- -- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index e9e1a31..f69efed 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.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 @@ -29,12 +29,22 @@ 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" -dt.configuration.check_version(...,{2,0,1},{3,0,0}) +local gettext = dt.gettext +dt.configuration.check_version(...,{3,0,0}) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +gettext.bindtextdomain("kml_export",dt.configuration.config_dir.."/lua/") +local function _(msgid) + return gettext.dgettext("kml_export", msgid) +end + +-- Sort a table local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua -- collect the keys local keys = {} @@ -59,7 +69,7 @@ local function spairs(_table, order) -- Code copied from http://stackoverflow.co end local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) - dt.print("Export Image "..tostring(number).."/"..tostring(total)) + dt.print(string.format(_("Export Image %i/%i"), number, total)) end local function checkIfBinExists(bin) @@ -92,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 @@ -109,32 +120,39 @@ 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,"%.", "_")) + 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(exported_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 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 "..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(exported_image) local pattern = "[/]?([^/]+)$" - filmName = string.match(_.film.path, pattern) + filmName = string.match(image.film.path, pattern) end exportKMLFilename = filmName..".kml" exportKMZFilename = filmName..".kmz" -- Create the KML file - kml_file = "\n" + local kml_file = "\n" kml_file = kml_file.."\n" kml_file = kml_file.."\n" @@ -142,15 +160,20 @@ 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 (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.."