Access and modify exposure from Lua in lighttable view

Hi,

I’m trying to build a Lua plugin that allows quick exposure adjustments for selected images directly from the lighttable view, avoiding the need to switch to darkroom for each image. The idea is to have basic ±EV buttons and a “match total exposures” function for batch editing. This would significantly speed up processing of image batches where there may be slight changes in auto shutter speed in the same lighting conditions.

To implement this, I need to:

  1. Read the current exposure value of each selected image.
  2. Apply modified exposure values programmatically.

Is it currently possible for a Lua script running in the lighttable view to:

  • Access the settings of a darkroom module
  • Change these settings via script?

Any guidance on whether this is feasible, or pointers to where to look?

I did see this older post Access Module Parameters via LUA which touches upon the same topic, but I wonder if the situation has changed in the last few years.

There is no introspection from Lua, so you can’t read the settings directly from the modules. Editing has to be done in darkroom view, since Lua is “editing” by controlling the UI, not by making changes directly to the modules internals.

You could set up styles with different exposure values and apply those to an image in lighttable from Lua. You could assign shortcuts to apply the various styles, then select an image and apply exposure styles until you get the look you want.

Thanks for the fast response.

That’s unfortunate… I don’t think styles would work for this use case, as they would just set a certain exposure level, while what I’m looking for is a way to quickly change exposure relatively to the current exposure of the image.

I suspect based on your comment that my only option would be to do something a bit hacky:

  • Get the XMP file path
  • Parse the XMP file to extract the exposure level
  • Generate a new .dtstyle that changes the exposure to the desired level
  • Apply the imported style to the image

Unless I’m mistaken all of those steps seem like they would be doable with a script.

Would a Lua script be able to do this:

  1. from lighttable, go into darkroom for an image
  2. make the OP’s desired exposure adjustment
  3. return to lighttable

I know this is a really poor solution, but it might save the OP a bit of time if it is possible. Take it with a huge grain of salt…I’ve yet to use Lua in darktable.

Yes.

Part of the problem is that Lua was never intended/permitted to “edit” images, and it really still doesn’t. What changed was that Lua gained the ability to manipulate the UI, so it could automate the manual gestures used to edit an image.

1 Like

Lua can create a style from an existing edit. Lua can’t “edit” the created style.

The real issue is that you can’t edit from lighttable. If you could, you could just assign a shortcut to the exposure module so that you could hold the shortcut and scroll to change the exposure.

1 Like

Thanks for the input and the suggestions. In the end I managed to get something to work with the workaround I was thinking about higher up in the thread…

In case anyone else is interested in enabling simple edits from the lighttable view, my protoype for quick ±EV adjustments and a “match exposure” function can be found here: darktable-lua-scripts/lighttable_exposure_controls.lua at main · hmoens/darktable-lua-scripts · GitHub

1 Like