Merge pull request #5 from darktable-org/master

changes from master
This commit is contained in:
supertobi
2016-01-13 13:43:53 +01:00
11 changed files with 54 additions and 32 deletions

View File

@@ -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})
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")

View File

@@ -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()

View File

@@ -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)

View File

@@ -33,7 +33,7 @@ USAGE
]]
local dt = require "darktable"
dt.configuration.check_version(...,{2,0,1})
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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
local kml_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
kml_file = kml_file.."<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
kml_file = kml_file.."<Document>\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.." <Placemark>\n"
kml_file = kml_file.." <name>"..image.filename.."</name>\n"
--kml_file = kml_file.." <description></description>\n"
if (image.title and image.title ~= "") then
kml_file = kml_file.." <name>"..image.title.."</name>\n"
else
kml_file = kml_file.." <name>"..image.filename.."</name>\n"
end
kml_file = kml_file.." <description>"..image.description.."</description>\n"
kml_file = kml_file.." <Style>\n"
kml_file = kml_file.." <IconStyle>\n"
@@ -197,7 +210,11 @@ local function create_kml_file(storage, image_table, extra_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
kml_file = kml_file.." "..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",0\n"
local altitude = 0;
if (image.elevation) then
altitude = image.elevation;
end
kml_file = kml_file.." "..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",altitude\n"
end
end
kml_file = kml_file.." </coordinates>\n"
@@ -222,7 +239,7 @@ local function create_kml_file(storage, image_table, extra_data)
local createKMZCommand = "zip --test --move --junk-paths "
createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" "
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..exportKMLFilename.."\" \""..dt.configuration.tmp_dir.."/"..imageFoldername.."\"*"
coroutine.yield("RUN_COMMAND", createKMZCommand)
coroutine.yield("RUN_COMMAND", createKMZCommand)
end
-- Open the file with the standard programm

View File

@@ -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

View File

@@ -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,

View File

@@ -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",

View File

@@ -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",

View File

@@ -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")

View File

@@ -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"}

View File

@@ -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",