Files
lua-scripts-w-api/contrib/hugin.lua
supertobi cc7ba37eb6 Added checkIfBinExists
Added a check to test if hugin is installed.
2015-09-09 10:03:01 +02:00

87 lines
2.3 KiB
Lua

--[[
Hugin storage for darktable
copyright (c) 2014 Wolfgang Goetz
copyright (c) 2015 Christian Kanzian
copyright (c) 2015 Tobias Jakobs
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 <http://www.gnu.org/licenses/>.
]]
--[[
HUGIN
Add a new storage option to send images to hugin.
Images are exported to darktable tmp dir first.
ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT
* hugin
USAGE
* require this file from your main luarc config file.
This plugin will add a new storage option and calls hugin after export.
]]
dt = require "darktable"
-- should work with darktable API version 2.0.0
dt.configuration.check_version(...,{2,0,0})
-- Register
dt.register_storage("module_hugin", "Hugin panorama", show_status, create_panorama, nil, nil)
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 show_status(storage, image, format, filename,
number, total, high_quality, extra_data)
dt.print("Export to hugin "..tostring(number).."/"..tostring(total))
end
local function create_panorama(storage, image_table, extra_data) --finalize
if not checkIfBinExists("hugin") then
return
end
-- list of exported images
local img_list
-- reset and create image list
img_list = ""
for _,v in pairs(image_table) do
img_list = img_list ..v.. " "
end
dt.print("Will try to stitch now")
if coroutine.yield("RUN_COMMAND","hugin "..img_list)
then
dt.print("Command hugin failed ...")
end
end
--
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua