Need your help with a lua script...

Hi all,

I have decided to try the waters of darktable lua scripting and wrote a little script to work around this bug: Sigma SD & DP cameras: White Balance and/or color calibration are off for DNGs · Issue #16586 · darktable-org/darktable · GitHub

(the bug in itself is a long story, tl;dr: The white balance setting is wrong, and unfortunately this can’t be mitigated using a preset due to a peculiarity of the white balance module)

The script provides a single “Fix Foveon DNG” button which corrects the white balance setting of the chosen image in a way that Sigma Foveon DNGs are displayed correctly.

This part functions just fine. But of course what I’d really like is a function that corrects a batch of just imported DNGs so that I don’t have to do it manually.

And here’s the problem. As I understand it, I would have to switch to the darkroom view to remote control the white balance module from my lua script.

I’m trying to do this in line 87 of my script:

                dt.gui.views.darkroom.display_image(image)
                fix_image()

but unfortunately this doesn’t seem to work. Also I have the nagging feeling this isn’t the ideal way to do this.

Can anybody in the know weigh in on this? I’m attaching the script to this post.

Many thanks in advance,
Stephan

fix_sigma_foveon_dngs.zip (2.1 KB)

First thought. Can you solve this with a style?

Open an image and turn off color calibration and set white balance to as shot. Save it as a style, then you could apply it after import using a while loop. Or, just select all the images and apply the style from the styles module.

Different option.

How about we set the script to make the change when the image is loaded into darkroom? When the images are imported the thumbnails are pulled from the images to populate the lighttable. It’s when you go to process the image that you need the fix. So, you could catch the darkroom-image-loaded event and then check if color calibration is enabled. If it is, apply your fix. If it’s not, then you’ve probably already applied your fix. Or, you could attach a tag darktable|Foveon Fix Applied when you fix it, then just add a check for the tag. This way it acts like an auto apply preset.

  dt.register_event("fix_sigma_foveon_dngs", "darkroom-image-loaded",
    function(event, clean, image)
      if clean then
        fix_image(image)
      end
    end 
  )
2 Likes

First thought. Can you solve this with a style?

Alas, no. When choosing “As Shot” in the White Balance modules, not the fact that “as shot is selected” gets saved in the preset (or style), but the actual white balance value. That’s kind of the whole problem :wink:

But…

Different option.
[…]

Great idea, works like a charm! :smiley: Thank you thank you thank you :blush:

I’ll clean up the script and then make it available for everyone (just in case there are other Sigma Foveon Quattro photographers besides me who would like to use darktable ;-))

Kind regards and thanks again,
Stephan

1 Like

If you would like, you can open a PR to add it to the lua-scripts repository, GitHub - darktable-org/lua-scripts

1 Like

Done: adds fix_sigma_foveon_dngs script by steph72 · Pull Request #578 · darktable-org/lua-scripts · GitHub

1 Like