Darktable and HDRmerge

Hello,
I have HDRmerge up and running on my Mac, Darktable too. I have tried to use the HDRMerge Lua Script, I have the correct executable.
When I click the “merge” button, nothing happens, no message.
Can somebody guess what is going wrong ?
Thanks,
Nicolas.

It would be better and more productive for you to start darktable from the terminal with the option -d lua and give us the output.

1 Like

Yes, thanks. I have a Lua error. Here is the output from the terminal.

(process:7389): GLib-GObject-CRITICAL **: 15:23:37.699: g_object_set: assertion ‘G_IS_OBJECT (object)’ failed

(process:7389): Gtk-WARNING **: 15:23:37.705: Locale not supported by C library.

Using the fallback ‘C’ locale.

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

[dt_pthread_create] info: bumping pthread’s stacksize from 524288 to 2097152

(darktable:7389): GLib-GObject-WARNING **: 15:23:37.921: invalid cast from ‘GtkMenuBar’ to ‘GtkWindow’

(darktable:7389): Gtk-CRITICAL **: 15:23:37.921: gtk_window_add_accel_group: assertion ‘GTK_IS_WINDOW (window)’ failed

39.236769 LUA ERROR : /Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:221: attempt to compare nil with number

stack traceback:

[C]: in metamethod ‘__lt’

/Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:221: in upvalue ‘main’

/Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:395: in function </Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:395>

[C]: in ?

Can anyone help please?
Nicolas

Please check if you have the latest version from the script and that line 221 looks like this:

Yes, thank you. It is exactly the same line.
Nicolas

Am I missing something. I downloaded the lua script folder directly from git.

For me the error doesn’t make sense. What is the image path and file name. Perhaps there is anything interesting.

Sorry I missed this. Here is what I think is happening. Up at the top of the script we declare

local function _(msgid)
    return gettext.dgettext('HDRMerge', msgid)
end

so _, which is normally used for an ignored value, is actually a function address. I think the function call is trying to replace the function _() with whatever is getting returned as the first value, which was meant to be ignored.

@nwinspeare, try changing _, on line 221 to _unused, and see if that fixes it.

1 Like

Sorry for taking so much time to answer, I have problems with my mail… I changed line 221 and it looks like this now : _unused, source_name, source_id = GetFileName

The error I get seems to be the same one although the line numbers have changed (the file I now have is an exact copy of the one in this post and we agree on what line 221 is) :

(darktable:5230): Gtk-CRITICAL **: 12:32:16.721: gtk_window_add_accel_group: assertion ‘GTK_IS_WINDOW (window)’ failed

4.873247 LUA ERROR : /Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:223: attempt to compare nil with number

stack traceback:

[C]: in metamethod ‘__lt’

/Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:223: in upvalue ‘main’

/Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:397: in function </Users/nick/.config/darktable/lua/contrib/HDRMerge.lua:397>

[C]: in ?

I added the line print(source_id) after source_id = tonumber(source_id) and the output is nil.

Thanks,
Nicolas

Please try to add this before line 221:

if (source_id == nil) then
    dt.print("source_id == nil")

dt.print(string.format("%i, %i, %i"), _, source_name, source_id)

What are the names of the files you are sending to HDRmerge. GetFileName returns the path, filename, sequence and extension from the argument. If you files were originally named DSC_1234.NEF it would return “”, “DSC_1234”, “1234”, “.NEF”. If you’ve renamed the files to something like “my_file_from_yesterday.NEF” then there would be no sequence number to detect and a nil would be returned.

Ahh, yes, that looks like a broken concept. Perhaps we should add:

if (source_id == nil) then
    source_id = 0
1 Like

I inserted the code like this

    local curr_image = image.path..os_path_seperator..image.filename
    HDRM.images_string = HDRM.images_string..df.sanitize_filename(curr_image)..' '
    out_path = image.path
    _, source_name, source_id = GetFileName(image.filename)
    source_id = tonumber(source_id)
    if (source_id == nil) then
        dt.print("source_id == nil")
        source_id = 0
    end
    dt.print(string.format("%i, %i, %i"), _, source_name, source_id)
    if source_id < smallest_id then 
        smallest_id = source_id
        smallest_name = source_name
        source_raw = image
    end

I added an “end” to the “if” and I inserted it after the attribution of a value to source-id. I get “source_id==nil” on output every time.
If I juste do dt.print(source_name) I get the name of my first selected file without an extension.
The line
dt.print(string.format("%i, %i, %i"), _, source_name, source_id)

crashes the script but when I add
source_id=0
then HDRMerge launches and I get a file back immediately. Not sure that the alignment is on or anything, I need to check. Big improvement.

My first file name by the way is “FUJIFILM-X-Pro3-2021-03-09-10h12min19s.raf” maybe the hyphons are creating an error?

I’ll do a few tests and come back to you. Thanks!

The root of the problem here is that we (I say we, because I’m probably the one that started this) assumed that image filenames would be the same as they were coming from the camera and we process them accordingly without checking to make sure they actually are what we thought they were.

I’ll try and look at this during the upcoming weekend and see if I can come up with a better solution, if someone doesn’t beat me to it.

Thank you Bill.
I admit that I rename all my files as I import them.
Other quick question… Why is the HDRMerge so fast? It is much much faster than if I use HDRMerge as a standalone and load the files from the hard drive.
Do I have a way from DarkTable to stay in HDRMerge and edit the merge (sometimes I get these weird artefacts that I paint over), then save and have the result imported into DT ?

Single mode seems to works fine but if I use the batch mode, I get an lua error

Writing /Volumes/LaCie/photos/shoots/2021/02/25/FUJIFILM-X-Pro3-2021-02-25-18h50min29s-.dng, 16-bit, 6246x4170
path lookup ‘/Volumes/LaCie/photos/shoots/2021/02/25/FUJIFILM-X-Pro3-2021-02-25-18h50min29s-0.dng’ fails with: ‘No such file or directory’

Thanks,N