diff --git a/contrib/de_DE/LC_MESSAGES/gimp.po b/contrib/de_DE/LC_MESSAGES/gimp.po new file mode 100644 index 0000000..b3b0447 --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/gimp.po @@ -0,0 +1,39 @@ +# 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: gimp\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-13 23:50-0400\n" +"PO-Revision-Date: 2016-04-14 00:11-0500\n" +"Last-Translator: Bill Ferguson \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.5.4\n" +"Language: de_DE\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2ngettext:1,2;" +"dngettext:2,3\n" +"X-Poedit-Basepath: .\n" + +#: gimp.lua:123 +#, lua-format +msgid "Export Image %i/%i" +msgstr "Exportiere Bild %i/%i" + +#: gimp.lua:129 +msgid "GIMP not found" +msgstr "GIMP nicht gefunden" + +#: gimp.lua:143 +msgid "Launching GIMP..." +msgstr "Starten von GIMP" + +#: gimp.lua:182 +msgid "Edit with GIMP" +msgstr "Bearbeiten mit Gimp" diff --git a/gimp.lua b/gimp.lua new file mode 100644 index 0000000..107a191 --- /dev/null +++ b/gimp.lua @@ -0,0 +1,186 @@ +--[[ + + gimp.lua - export and edit with GIMP + + Copyright (C) 2016 Bill Ferguson . + + Portions are lifted from hugin.lua and thus are + + Copyright (c) 2014 Wolfgang Goetz + Copyright (c) 2015 Christian Kanzian + Copyright (c) 2015 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 . +]] +--[[ + gimp - export an image and open with GIMP for editing + + This script provides another storage (export target) for darktable. Selected + images are exported in the specified format to temporary storage. GIMP is launched + and opens the files. After editing, the exported images are overwritten to save the + changes. When GIMP exits, the exported files are moved into the current collection + and imported into the database. The imported files then show up grouped with the + originally selected images. + + ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT + * GIMP - http://www.gimp.org + + USAGE + * require this script from your main lua file + * select an image or images for editing with GIMP + * in the export dialog select "Edit with GIMP" and select the format and bit depth for the + exported image + * Press "export" + * Edit the image with GIMP then save the changes with File->Overwrite.... + * Exit GIMP + * The edited image will be imported and grouped with the original image + + CAVEATS + * Developed and tested on Ubuntu 14.04 LTS with darktable 2.0.3 and GIMP 2.9.3 (development version with + > 8 bit color) + * There is no provision for dealing with the xcf files generated by GIMP, since darktable doesn't deal with + them. You may want to save the xcf file if you intend on doing further edits to the image or need to save + the layers used. Where you save them is up to you. + + BUGS, COMMENTS, SUGGESTIONS + * Send to Bill Ferguson, wpferguson@gmail.com +]] + +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("gimp",dt.configuration.config_dir.."/lua/") + +-- Thanks to http://lua-users.org/wiki/SplitJoin for the split and split_path functions +local function split(str, pat) + local t = {} -- NOTE: use {n = 0} in Lua-5.0 + local fpat = "(.-)" .. pat + local last_end = 1 + local s, e, cap = str:find(fpat, 1) + while s do + if s ~= 1 or cap ~= "" then + table.insert(t,cap) + end + last_end = e+1 + s, e, cap = str:find(fpat, last_end) + end + if last_end <= #str then + cap = str:sub(last_end) + table.insert(t, cap) + end + return t +end + +local function split_path(str) + return split(str,'[\\/]+') +end + +local function get_filename(str) + parts = split_path(str) + return parts[#parts] +end + +local function basename(str) + return string.sub(str,1,-4) +end + +local function _(msgid) + return gettext.dgettext("gimp", msgid) +end + +local function checkIfBinExists(bin) + local handle = io.popen("which "..bin) + local result = handle:read() + local ret + handle:close() + if (result) then + dt.print_error("true checkIfBinExists: "..bin) + ret = true + else + dt.print_error(bin.." not found") + ret = false + end + return ret +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)) +-- dt.print(_(string.format("Exporting to gimp %i/%i", number, total))) +end + +local function gimp_edit(storage, image_table, extra_data) --finalize + if not checkIfBinExists("gimp") then + dt.print_error(_("GIMP not found")) + return + end + + -- list of exported images + local img_list + + -- reset and create image list + img_list = "" + + for _,exp_img in pairs(image_table) do + img_list = img_list ..exp_img.. " " + end + + dt.print(_("Launching GIMP...")) + + local gimpStartCommand + gimpStartCommand = "gimp "..img_list + + dt.print_error(gimpStartCommand) + + coroutine.yield("RUN_COMMAND", gimpStartCommand) + + -- for each of the exported images + -- find the matching original image + -- then move the exported image into the directory with the original + -- then import the image into the database which will group it with the original + -- and then copy over any tags other than darktable tags + + for _,exp_img in pairs(image_table) do + local fname = get_filename(exp_img) + dt.print_error(fname) + for _,orig_img in pairs(dt.gui.action_images) do + if basename(fname) == basename(orig_img.filename) then + dt.print_error("moving file...") + local myimage_name = orig_img.path .. "/" .. fname + dt.print_error(myimage_name) + result = os.rename(exp_img, myimage_name) + dt.print_error("importing file") + local myimage = dt.database.import(myimage_name) + for _,tag in pairs(dt.tags.get_tags(orig_img)) do + if not (string.sub(tag.name,1,9) == "darktable") then + dt.print_error("attaching tag") + dt.tags.attach(tag,myimage) + end + end + end + end + end + +end + +-- Register +dt.register_storage("module_gimp", _("Edit with GIMP"), show_status, gimp_edit) + +-- + +