How I wrote in in this post I feel DT is missing a good way to manage external editors.
Some lua scripts are available for Gimp that can be adapted to other programs, but what I wanted was a way to manage multiple programs, even applied in sequence to the same image, not being forced to export the image at every step, creating a new TIF.
So I wrote this lua script, which at the moment is only tested on Windows and for sure need to be refined.
the scripts adds:
a new target storage “collection”. Images exported will be reimported to collection for further edit with external programs
a new lighttable module “external editors”, to select a program from a list of up to 9 external editors and run it on one selected image
a set of lua preferences in order to configure name and path for up to 9 external editors
a set of lua shortcuts in order to quick launch the external editors
More info in the file header.
Hope it can be useful, comments welcome.
I would like to add another button to the lua module. It becomes like this:
I can’t figure out how to make the two buttons equal in size and taking all the horizontal space, like the other modules, for example:
Any clue ?
The script now works also without leaving darkroom mode, which is very handy.
Just configure export destination to “collection” before entering darkroom.
From there, CTRL+E will create a new image for external edit.
To edit an image from darkroom, configure and use shortcuts. The image view will be updated when leaving the external program. The script is now tested in Windows 10 and Ubuntu 19.10.
I created a PR in git
@MarcoNex
nice one, i tested your script and if works well for the UI part, but not so for one line. It is the one exporting / piping output to a MacOs application:
I would need some help to correct the code below:
if dt.configuration.running_os == "macos" then
program_paths[i] = "open -W -a " .. program_names[i]
else
program_paths[i] = df.sanitize_filename(dt.preferences.read(MODULE_NAME, "program_path_"..i, "string"))
end
on MacOs, the executables are stored inside a file package, like so: Gimp.app/Contents/Resouces/MacOs/Gimp
therefore i tried also with "program_path_".."Gimp.app/Contents/Resouces/MacOs/"..i
…before the grab from the code exporting to Gimp, you’d cited before. But it does not work in both cases. Maybe i am just mistyping something or forgetting sth.
Works great on Macs, I’ve used the other plugin that exports pictures to gimp only. Likewise you, I’m also interested to export to other external editors as well.
After successful execution, this commands logs :
LUA open -W -a '/Applications/Gimp-2.10.app' 'path/to/temporary/items/folder/picture.jpg'
Of course, this command “opens” a target file, so it this call needs to be added when the external editor is triggered and not, when the path to the editor is being registered
For the other path (trying to concatenate strings)
I’ve had no success, even after adding the whole path to the executable
preferences >Lua options >executable for external editor 1
Then in lua preferences, in “executable for external editor 1” put “gimp” (without quotes) and in “name of external editor 1” put a friendly name for it (“Gimp”, or “GNU Image Processor”, or whatever you like to see in the drop down list).
If it works, do the same with the other programs, you just need to find which command to use from the terminal.
I tried with /Applications/GIMP.app /GIMP.app /GIMP GIMP.app GIMP
in the path field, and tried again both of your attachments
and wrote the names capitalized as they are (case sensitive). On Mac, my Gimp.app sits in the Application folder which is parent to root /Applications/GIMP.app
and i am still getting GIMP not found
The lines 126-129 must be responsible for the path string. A dt.print dialog could inform if we found the right path. But, i have also to add and to illustrate more my idea, usually in bash shell script you do not need no path, when launching an app, but only the name of the application package (e.g. “GIMP.app”) to launch the requested process. The "open -W -a " command looks more like a command which does not need paths. I could be wrong.
Anyway, maybe you want to try out some more ideas, if not thanks nevertheless.
Good try. But I’ll be honest, it’s still not working.
I can just guess how to change the code as I’ve no idea about Lua
Ok, let’s try another one…
The gimp.lua script needs a file path to the application bundle, ("/Applications/GIMP.app") so let’s go back to how your original script worked,
replacing the text field of “executable for external editor” with a path chooser popup menu
Name of external editor
Executable for external editor
We should be closer to a solution, because we know how to open files, but the path needs still some tweaking
local gimp_executable = df.check_if_bin_exists("gimp")
...
if dt.configuration.running_os == "macos" then
gimp_executable = "open -W -a " .. gimp_executable
end
There is no path to application bundle, the program command “gimp” is hardcoded and the filepath is supposed to be returned by the library function df.check_if_bin_exists("gimp")
Now this is what the last version of my script does:
local bin = df.check_if_bin_exists(program_paths[choice])
...
if dt.configuration.running_os == "macos" then bin = "open -W -a "..bin end
Which is completely the same if you put “gimp” in executable for editor 1.
I checked /compared both your script and gimp.lua with VisualStudio Code to see if I can do something, with darktable launched from terminal to see what errors might pop up.
I would add more error dialog traps to see what path your script picks up
Yes, apparently gimp.lua needs no path, but it does. The script is an extension of the default export pictures module, so it might get some informations from there.
As much as I get from this picture, is that the first line defines /switches on an option, which is only a string for the ui, unrelated to a path
The second line defines the path of the executable to launch upon successful export.
The path needs Not to get the full path to the executable itself (e. G. /Applications/GIMP.app/Contents/MacOs/gimp) , but is yet happy to get a path to the application bundle (e. G. /Applications/GIMP.app)
I’m puzzled why your original external editor launcher script didn’t work, a path specification is the best way to launch external files.
Yeah, I see what you mean, but the “select gimp executable” widget seems disconnected from the rest of the code.
Actually, gimp.lua desn’t even work to me on Windows, some scrips just look like abandoned these days…
Try to put whatever other file from the “select gimp executable” widget. Does Gimp start anyway ?
Interesting. The label gimp doesn’t mean anything, it’s only the most obvious choice for retouching pictures (at least for Linux machines), Dt is basically a Linux app.
If I choose another application it launches and opens pictures in another application, as I want.
The Pop up messages /ui labels use the name gimp, but only because that label itself isn’t a variable.