Skip to content

Add metadata query to Lua API#20968

Open
wpferguson wants to merge 1 commit intodarktable-org:masterfrom
wpferguson:add_metadata_to_lua_api
Open

Add metadata query to Lua API#20968
wpferguson wants to merge 1 commit intodarktable-org:masterfrom
wpferguson:add_metadata_to_lua_api

Conversation

@wpferguson
Copy link
Copy Markdown
Member

@wpferguson wpferguson commented May 8, 2026

#20872 added the ability for users to add additional metadata fields that are populated on image import.

The Lua API adds those fields to the dt_lua_image_t datatype as accessible members.

If you try and access a dt_lua_image_t member that doesn't exist, Lua throws an error that stops script execution. The error can't be caught with a pcall().

The fix is adding some metadata functionality to the Lua API. This PR adds a darktable.metadata.exists(<exif tag name>) function to the API that returns true or false based on whether a user has registered the metadata in metadata editor. Scripts can use this information to decide whether to spawn an external executable (exiv2 or exiftool) to get metadata or use the internal metadata.

Currently the metadata section only includes exists(). Future functionality could be added to add and remove additional metadata tags without the user having to intervene. With the short time until feature freeze exists() is a needed feature and the others can wait.


To test...

  • Download the attached script, unzip it and add it to lua scripts
  • start darktable with the -d lua flag
  • add tag Exif.Canon.RawBurstModeRoll to metadata editor.
  • start the test_metadata_api.lua
  • check the log for "found Exif.Canon.RawBurstModeRoll"
  • remove Exif.Canon.RawBurstModeRoll from metadata editor
  • restart darktable
  • check the log for "didn't find Exif.Canon.RawBurstModeRoll"

test_metadata_api.zip

@wpferguson wpferguson added feature: new new features to add lua labels May 8, 2026
@wpferguson wpferguson requested a review from zisoft May 8, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: new new features to add lua

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant