If exiftool was somehow linked into darktable, then we could possibly access it to query exif information in an image. But, exiftool is a perl script, so we’d either have to embed perl in darktable or port the script to Lua.
The EXIF information darktable extracts is just common image info such as
exiftool is updated more often (last release 11 days ago) and easier to get data out of (at least for a script). It also seems to track camera firmware releases better and offers fields that exiv2 doesn’t.
The roll and pitch data I referred to above is not available in exiv2 0.27.5 which is current on my system (Ubuntu 22.04). For Ubuntu 24.04 exiv is at 0.27.6. Current exiv2 is at 0.28.7. darktable doesn’t have a requirement for a specific version, it just has to be greater than or equal to 0.27.x.
Having said all of that, there are times that I use exiv2 and spawn it. I’ll look into adding an internal interface to the API.
Here’s the script. In the determine_correction() I’ve documented the roll angles and what they correspond to. If your camera works the same way then you’re in business. If it doesn’t, then you’ll have to adjust the sign of the correction returned. If your camera has different axis values, please let me know and I’ll incorporate it into the script.
I’ve added another script that will dump the roll and pitch angles when you hover over an image or select it.
Thanks Bill! For some reason I don’t understand why it doesn’t have any effect on my side …
Script is starting, exiftool is available, I see the new option in settings, shortcut event is registered, but when the image is loaded in darkroom nothing happens …
What is the variable clean in the event darkroom-image-loaded?
Sometimes the darkroom-image-loaded event fires but the image hasn’t finished loading in darkroom. When clean is set to true the image has finished loading and is safe to use.
Do your raw images have Roll and Pitch angle data?
If you have the dump_roll_angle.lua script running then each time you hover over an image you should see a message with the roll and pitch angle information.
Ok, found the issue: file name and/or path contains spaces and exiftool exits with error (file not found). The fix would be to mark it with double quotes: local pipe = io.popen(as.exiftool .. " -RollAngle -PitchAngle " .. '"' .. image.path .. PS .. image.filename .. '"')