open_ooc
This commit is contained in:
127
open_ooc.lua
Normal file
127
open_ooc.lua
Normal file
@@ -0,0 +1,127 @@
|
||||
--[[
|
||||
|
||||
ext_proc.lua - export and process with an arbitrary binary
|
||||
|
||||
Copyright (C) 2025 Florian Tham <fgtham@gmail.com>.
|
||||
|
||||
Heavily based on gimp.lua and thus is
|
||||
|
||||
Copyright (c) 2016 Bill Ferguson
|
||||
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
]]
|
||||
--[[
|
||||
open_ooc - open associated out-of-camera jpeg for selected raw files
|
||||
|
||||
This script opens jpeg files for selected raw files. This helps when ignoring
|
||||
jpegs on import, but you want to view the jpeg nontheless.
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
* select an image or images
|
||||
* in the "selected images" section, press "open ooc jpeg"
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* Send to Florian Tham, fgtham@gmail.com
|
||||
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local df = require "lib/dtutils.file"
|
||||
local dtsys = require "lib/dtutils.system"
|
||||
local ooc_widget = nil
|
||||
|
||||
local wg = {}
|
||||
|
||||
local MODULE = "open_ooc"
|
||||
|
||||
du.check_min_api_version("7.0.0", MODULE)
|
||||
|
||||
-- from https://github.com/ChristianBirzer/darktable_extra_scripts/blob/main/HeliconFocus.lua
|
||||
-- find locale directory:
|
||||
local os_path_seperator = "/"
|
||||
local scriptfile = debug.getinfo( 1, "S" )
|
||||
local localedir = dt.configuration.config_dir..'/lua/locale/'
|
||||
if scriptfile ~= nil and scriptfile.source ~= nil then
|
||||
local path = scriptfile.source:match( "[^@].*[/\\]" )
|
||||
localedir = path..os_path_seperator..'locale'
|
||||
end
|
||||
dt.print_log( "localedir: "..localedir )
|
||||
|
||||
local gettext = dt.gettext
|
||||
gettext.bindtextdomain(MODULE, localedir)
|
||||
|
||||
local function _(msgid)
|
||||
return gettext.dgettext(MODULE, msgid)
|
||||
end
|
||||
|
||||
-- return data structure for script_manager
|
||||
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("open OoC JPEG"),
|
||||
purpose = _("open associated OoC JPEGs for selected RAW files"),
|
||||
author = "Florian Tham <fgtham@gmail.com>",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/open_ooc"
|
||||
}
|
||||
|
||||
script_data.destroy = nil -- function to destory the script
|
||||
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
script_data.show = nil -- only required for libs since the destroy_method only hides them
|
||||
|
||||
local function open_ooc() --finalize
|
||||
local images = dt.gui.selection()
|
||||
local file_list = ""
|
||||
|
||||
if #images == 0 then
|
||||
dt.print(_("please select an image"))
|
||||
return
|
||||
end
|
||||
|
||||
for _, image in pairs(images) do
|
||||
file_list = file_list .. image .. " "
|
||||
dt.print(image)
|
||||
end
|
||||
dt.print(file_list)
|
||||
end
|
||||
|
||||
|
||||
local function destroy()
|
||||
dt.gui.libs.image.destroy_actin(MODULE)
|
||||
dt.destroy_event(MODULE, "shortcut")
|
||||
end
|
||||
|
||||
-- Register
|
||||
|
||||
dt.gui.libs.image.register_action(
|
||||
MODULE, _("open associated OoC JPEGs"),
|
||||
function() open_ooc() end,
|
||||
_("open associated OoC JPEGs for the selected raw files")
|
||||
)
|
||||
|
||||
dt.register_event(
|
||||
MODULE,
|
||||
"shortcut",
|
||||
function(event, shortcut), open_ooc() end,
|
||||
MODULE
|
||||
)
|
||||
|
||||
--
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
Reference in New Issue
Block a user