Working with modules from Lua scripts in darktable

@priort Thank you for the feedback :slight_smile:

If you are using dt4.1 you can speed it up by using the new event “pixelpipe-processing-complete”. To do that, edit function WaitForPixelPipe and replace darkroom-image-history-changed with pixelpipe-processing-complete.

The note on legacy white balance is correct. I use the modern workflow. I will try to add a check to the script.

Best regards,
Uli.

2 Likes

darktable.gui.action() only provides a way to manipulate the GUI.

My solution so far is to use a combination of styles (with a lot of modules turned off) and darktable.gui.action() to manipulate the style (turn modules on and off, manipulate the settings, etc). I built the equivalent style using darktable.gui.action() and it is slow.

You could have a script that caught the darkroom-image-loaded event, then checked to see if the image had been processed or not. If not, then a style could be applied using darktable.styles(), then manipulated using darktable.gui.action().

2 Likes

That is an interesting approach… I guess the only thing here is Ulrich is firing off auto exposure and black and white levels in filmic so no way to do that with your approach at least I don’t think. But it could be useful for other edits …

You could do it the first time you open the image, after you’ve applied the style. You could set a tag after you’ve done the auto levels/exposure or just check the status of exposure and see if it’s set to auto. I haven’t had time to look at the script yet, so those are just off the top of my head.

I think he is doing what I do now and using the picker with the spot exposure setting to 50% to give the base starting point…. This works pretty well. I do this with new images and then if I don’t like it I can select the main area of interest and it will boost or drop exposure…. I don’t think he is using the auto setting of the exposure module….

Hi @priort and @wpferguson ,

there is a new version of my script, you can find it attached. In the end, this script executes some automatic functions that can also be accessed via the GUI (click the magic wands).

With Darktable 4.2, this script has been accelerated. It uses the new “pixelpipe-processing-complete event”. It should be about twice as fast (less thread.sleep()).

From now, the white balance is only adjusted by default for the modern workflow of Darktable. The script distinguishes between modern and legacy workflow and keeps white balance unchanged by default, if using legacy workflow.

It was a little bit difficult to figure out how to do this: dt.preferences.read(“darktable”, “plugins/darkroom/chromatic-adaptation”, “string”). The documenation points to another way: “The name of the preference displayed in the preference screen”, I assumed “auto-apply chromatic adaptation defaults”.

I am looking forward to your comments :slight_smile:

InitialWorkflowModule.zip (4.9 KB)

Best Regards,
Uli.

by the way: Many thanks to all developers of DT! For me it is one of the most exciting software projects and I am very happy that DT exists! It’s open source, it runs on Linux, it’s always evolving, it can be automated and so on - and I have nicer pictures :slight_smile: . Thank you very much!

6 Likes

@Claes there is a new version of my script, perhaps this can be helpful.

Best Regards,
Uli.

Danke vielmals :slight_smile:

Thanks for sharing. I have promoted it a few times and shown a screen shot of the layout…I get back hey what module is that, what version of DT are you running… :slight_smile:

I must say I have not put it to good use yet as I have been really busy at work and have really not had any photo’s to edit but I will install this new one and check it out… I will do a few tests… I think you pointed me to that function in our initial discussion and I had made the change so maybe I won’t notice that 2x bump but never the less thanks it really shows what is possible…

I think one nice addition if you can figure it out would be to set the auto pickers for the rgb CB module mask… the white fulcrum and contrast grey to set up the mask for the tonal ranges…

image

2 Likes

Hi @priort , thank you for the promotion :slight_smile:

Yes, that is based on the start of the discussion and the new event you implemented. This is very useful. Performance is already “normal” for you as developer, so you won’t see any gain in performance.

You propose an extension for the color calibration module. I’ll look at that in two weeks after my vacation, that should be easy to do.

Best regards,
Uli.

This is awesome news! That’s exactly what I was looking for last year!

I wonder what kind of “dynamic preset” shenanigans we can come up with, with this capability. Most of my immediate ideas would involve some sort of measurements, though. I could probably fake an approximate exposure estimate by, say, enabling the auto mask exposure compensation in the tone equalizer, and then reading the mask exposure compensation value.

Or is it possible to place/read color pickers? One could even imagine placing several pickers over various image parts, to do weighted exposure evaluations. Information about under- or overexposed areas might also be useful…

I can’t wait to play with this!

It runs the exposure auto picker which by default is 50 percent that works a lot of the time but you could adjust it if not…

Happy New Year…

Given this topic a way of working in whether to use filmic or sigmoid when running the script might be of interest to many as well…

1 Like

Some of the latest code seems to have broken your script… it seems to cycle through multiple times. I even saw the local contrast module appear and then disappear??

Just built for the first time after the multiple auto presets for the same module code has been added. I wonder if that might be part of the issue?? Also there are new options in processing preferences to denote the default workflow…

Hi @priort ,

I am running DT4.2 on Linux (EndeavourOs) for my daily work. So I’m not using the latest developer version. I will execute the script in a virtual machine with the newest Arch / EndeavourOs version.

In the last few days I’ve made some changes locally. However, the script still does not use the local contrast module, the ID “iop/bilat” is not found in the code.

So maybe it really has something to do with the latest build?

Did you use “darktabe -d lua”? This will output some logs. Does the script run in a loop?

Best regards,
Uli.

Yes it seemed to run in a loop sometimes it looked like 4 or 5 times and in the end but not always often did land with the right adjustments and other times not…

The have changed the workflow settings in preferences now… There is single preference with 4 options… none sigmoid filmic basecurve… There are no settings now for wb. So the only way to get legacy wb by default read from the camera is to set this to none… You can then add an auto preset for filmic but it will not update rel white and black so your script will come in handy for those wanting to keep using legacy wb as a default… also the multiple auto presets/module and auto renaming might also interact with your script on some level but I don’t have the knowledge to say for sure…

1 Like

Hi,

I tried to execute the script in a virtual machine with the newest Arch / EndeavourOs version, but no packages are available. Do you know, when Darktable 4.3 will be available in Arch (AUR)?

Is there another way, to execute DT 4.3?

BR,
Uli.

I guess you would just have to build it… not too hard but maybe not worth fiddling… none of these would work for you I don’t think . I don’t know that much about Arch…

There should be a darktable-git package in the AUR AUR (en) - darktable-git

yes, but it was last updated on 2022-10-25 for DT4.1, not DT4.3.