Bug 449170 - Digikam fails to import RAW from darktable 3.8.0
Summary: Digikam fails to import RAW from darktable 3.8.0
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-RawImport-Darktable (show other bugs)
Version: 7.6.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-25 19:26 UTC by Joshua Goins
Modified: 2022-01-26 04:04 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.6.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Goins 2022-01-25 19:26:54 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Install Digikam 7.6.0 and Darktable 3.8.0
2. Set Digikam to import RAW with Darktable
3. RAW fails to import from Darktable when Darktable is closed

OBSERVED RESULT
The regular "Failed to import RAW from Darktable" dialog shows up, and nothing is ever modified or changed.

EXPECTED RESULT
To import the RAW modified from Darktable.

SOFTWARE/OS VERSIONS
Windows: N/A
macOS: N/A
Linux/KDE Plasma: Fedora Linux 35
(available in About System)
KDE Plasma Version: 5.32.4
KDE Frameworks Version: 5.89.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
I actually have the solution to the bug(?) that was apparently fixed in GIMP as well, file and relevant commit is located here: https://gitlab.gnome.org/GNOME/gimp/blob/master/plug-ins/file-raw/file-darktable-export-on-exit.lua. 
According to the latest commit (from 11 months ago?), it seems something changed in the Darktable Lua API.

From my understanding, the way Digikam uses Darktable for a RAW import tool is by calling Darktable externally, and using a lua script and setting a conf variable it's able to get Darktable to import the original image, and export it to /tmp. Conveniently, the lua script that's getting called is also located in /tmp. For the purposes of my testing below, I intentionally crashed Digikam so the lua script is kept in place, and copied the Darktable command from KSysGuard.

For some reason, replacing this script that is copied into the temp folder with the one from GIMP above shows that the RAW image from Darktable is now being correctly written back to /tmp, unlike the original script from Digikam. I haven't tried seeing if this would actually fix the bug in Digikam but it appears to work when I copy the same commands that Digikam calls Darktable. I'd gladly write up a PR or patch if wanted.

It also seems like others have the same issue (https://www.reddit.com/r/DarkTable/comments/qewckg/darktable_can_no_longer_edit_files_straight_from/) but this not related to 445216 or 414484 (which deals with macOS and Window issues respectively, and completely unrelated bugs).
Comment 1 caulier.gilles 2022-01-25 19:38:03 UTC
hi,

yes, it's LUA used to deal with darktable. script is here :

https://invent.kde.org/graphics/digikam/-/blob/master/core/dplugins/rawimport/darktable/rawimportdarktableplugin.cpp#L71

If you know the difference with the Gimp lua script, a patch or a MR in gitlab is welcome

Best

Gilles Caulier
Comment 2 Joshua Goins 2022-01-25 19:40:27 UTC
(In reply to caulier.gilles from comment #1)
> hi,
> 
> yes, it's LUA used to deal with darktable. script is here :
> 
> https://invent.kde.org/graphics/digikam/-/blob/master/core/dplugins/
> rawimport/darktable/rawimportdarktableplugin.cpp#L71
> 
> If you know the difference with the Gimp lua script, a patch or a MR in
> gitlab is welcome
> 
> Best
> 
> Gilles Caulier

Yes thank you :-) I'm compiling Darktable as we speak as I think I see what the problem is now.
Comment 3 Bug Janitor Service 2022-01-25 20:32:08 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/digikam/-/merge_requests/159
Comment 4 Nicolás Alvarez 2022-01-25 21:52:05 UTC
Fixed in: https://invent.kde.org/graphics/digikam/commit/9a7de4cf4ce8c3bf776889139874787aa6247685

> Fix Darktable RAW import for versions above 6.2.1
> 
> This also checks if your API version is actually >= 6.2.1 before calling, similar to how GIMP does it.
> I wrote my version a little cleaner though ;-)