An external editor launcher lua script (for Windows and Linux)

Good, I think we are close to a solution.

The right filepath seems to be /Applications/GIMP.app therefore, according to what gimp.lua does, the command
open -W -a /Applications/Gimp.app
should launch Gimp, can you please try in a terminal ?

If so, I hope this version does the trick (please configure /Applications/GIMP.app for program 1)
ext_editor.lua.txt (14.2 KB)

The other two lines in darktablerc are leftovers from our previous attempts, you can delete them.

1 Like

Good job, Gimp launches and opens the selected picture of Dt
Right now it works only with Gimp, other image editors are being ignored

Please configure the executables in the lua preferences, like you did for Gimp and press the update list button in the external editors module in lighttable:
Cattura14
Then you should be able to choose the program in the dropdown list and run it.
If it doesn’t work, please give me one example.
You can also configure keyboard shortcuts to launch each editor.
That, combined with the “export to collection” feature provided by the script, and the ability to export and launch the editor from inside darkroom, makes the whole process very handy.

I see now what’s going on - the export feature is limited to one export at a time.

And I can export only once from Dt, even if I call the same external editor.
This issue must be caused due to the fact that launching and exporting are combined in your script.

If your script launches first the application and exports then, the issue should be solved.

Not really.
The script provides an additional export recipe “export to collection” which exports in the collection folder and reimport the exported images in the collection.
From lighttable, you can export as many images as you like, while from darkroom you can export one image only with CTRL+E (or the equivalent in Mac).
This is no different from any other export recipe, it’s just how DT works.
After you exported, typically to a 16 bit tiff, you can then launch the editor you choose, one image at a time (as sending multiple images to the same editor has unpredictable results, depending on the specific editor).
The script should give you an error if you try to launch an editor on a raw image.
You can launch editors from lighttable with dropdown list and the buttons “edit” and “edit a copy”, or from inside darkroom, by using keyboard shortcuts you have previously configured for each editor. The latter, is the feature I find more useful.
This is how it works in Windows and Linux. If you notice a different behaviour in Mac, please let me know.

I hadn’t tried to export multiple images in a shot.
What I did is following:

I selected 1 image in Dt lightroom, clicked on the edit button of your script, had Gimp as my preferred external editor selected.

Gimp launched and opened the picture, as expected. So far so good
Now, I after my edits in gimp I wanted to export yet another picture from darktable to the gimp. So I did, but this time, nothing happened :hushed:

Then I tried with another image editor. Nothing either
Only after quitting the gimp, Gimp launched again with the image I wanted to process.

Basically, this work flow forces me to quit the editors each time if I wanna export yet another picture, no matter if the editor is already open or not.

Because of this behavior I guessed that the export command hadn’t completed yet, and was effectively keeping both darktable and the external editor in idle prior to listen for new commands.

Maybe your script is working but not so my preferences - maybe they’re messed up from scripting. Coding is like that.
I shall try to trash darktablerc

Do not trash darktablerc, you will lose all your preferences, it’s enough to delete all lines that start with lua/

This behaviour is not normal, I would need to know the lua debugging output.
On Windows and Linux, it is activated launching darktable from the command line
darktable -d lua
If you manage to run it, do the operation which is not working and post the console output.

By the way, the expected workflow is to use external programs as plugins of DT, so for example in Gimp you should do “File → overwite” and then close the program before you launch another edit.
I guess you know that, but just to double check.

Hi there. I’m just writing in this thread because I’m trying to run your script on Windows 10 and I’m having some problems. I’ve tried using Photoshop and Affinity Photo as external editors but whenever I choose a RAW file to edit (NEF) DT shows the message “file type not allowed”. I’ve repeated the process by using a Jpg file and both AF and Photoshop open the file without problem. Do I have to configure something else? Am I missing something? I’m new to DT and I would love this feature to work as its important for my workflow.
Thanks.

Yes, this is by design.
The script is made to allow round trips with external editors, but the pivot point remains DT.
You can’t use RAW for round trips because DT would not be able to read the changes done elsewhere.
I suggest you first use the “export to collection” feature of the script, using tiff 16 bit as exchange format and then edit the tiff in whatever program.

Ah, ok. Thanks a lot, I thought the script would export directly to TIFF. My mistake.
So I have to export to TIFF and then send to the external editor. Understood.
Thanks again.

Yes, but in the export module, choose “collection”, so that the tiff file will be reimported to DT and you will find it next to your RAW.
On a side note, you can do all this without leaving the darkroom

Yes, now I’ve got the grasp of it. It’s a bit difficult sometimes to get something new when one has been used to a different workflow for quite a time.
Thanks again for your quick answer and explanations.

2 Likes

Just after exporting file I see message “error moving file c:\users\darek\appadata\local\temp\filename.tiff”

What to do ?

Windows 11, DT4.2, original arw file exist on synology shared folder

Darek K

How about if you try with a local file first to see is you get the same error…maybe something is timing out or there is some write permission issue in the Appdata folder…

Just copy a raw to the desktop and open it and try to run again…

This is line 326 in this script move_success = df.file_move(temp_name, new_name)
I think there is a bug in this function.
When new_name has normal english letters it works fine but when new_name has polish letters (ą,ę,ń) it returns error.

Regarding to this Lua: how to make os.rename & os.remove work with filenames containing unicode characters? - Stack Overflow
I found solution here UTF-8 filenames on Windows in pure Lua · GitHub
But I don;t know where and what I have to do.
Where to put utf8_filenames.lua and where insert require lines and require = what ?

Darek

It would be nice to be able to send it directly to the editor, so that the editor opens automatically when exporting the .tiff file. Another thing is, that sometimes the .tiff opens in the external editor after exporting to collection, when selecting the .tiff in lighttable and clicking ‘edit’ in the right panel, but more often it does not open and I get the message ‘error launching Affinity Photo’. And then I have to go to the collection and open the .tiff in the editor myself. I don’t know why it has not not been made possible to open a .tiff in the editor with just one click, like Lightroom, ART and RawTherapee.

Jan.

The export to collection function can work on multiple files at once, while the “edit” or “edit a copy” functions inside the ext_editor script work only on one file.
The use case I imagined was:

  • edit one or more files in DT
  • export them to collection; that’s your base version
  • one by one, edit or better edit copy in external editor, so you have before and after

But of course anyone is free to propose a PR to change the behaviour