Skip to content

Conversation

@horazont
Copy link
Contributor

@horazont horazont commented Nov 4, 2025

This is a follow-up from #19622, where @zisoft pointed out that there's a mechanism to read custom EXIF tags into darktable's database for filtering and such. That didn't work, so I cobbled together this patch.

This does not fully work yet. For some reason, on first import of an image, the metadata is not set. I have to reread the EXIF data manually via the UI in order for it to appear. Any ideas why that might be welcome.

@zisoft
Copy link
Collaborator

zisoft commented Nov 4, 2025

I am currently busy with the gtk4 migration, so great you have a look here.

The metadata customization dialogue does offer Exif.* tags, but
they were not actually read from EXIF. This commit fixes that
behaviour.
Through the call chain dt_image_import ->
_image_import_internal -> dt_exif_xmp_read -> _exif_decode_xmp_data, the
function _exif_decode_xmp_data would be called with exif_read == FALSE,
causing it to delete all metadata which has previously been read in
_exif_decode_exif_data (see the parent commit).

The intent was likely to be able to update descriptions etc. which had
been written through other programs in the Xmp files in darktable. In
order to continue to support this use case, we do still remove
Xmp-related tags if we don't find them in the sidecar, but only those
(via a string match).
@horazont horazont force-pushed the fix/custom-metadata-exif-read branch from 4b95f8e to a0af003 Compare November 4, 2025 16:21
@horazont horazont marked this pull request as ready for review November 4, 2025 16:22
@horazont
Copy link
Contributor Author

horazont commented Nov 4, 2025

Figured it out! The xmp read was called with exif_read == FALSE, leading to a dt_metadata_clear call. I fixed that in a manner which hopefully makes sense.

EDIT: I'm not exactly sure in which case the exif_read == FALSE code path should be triggered except on image import, so I don't know how to test that I didn't break anything... I tried to look through the usages of the various functions, but I seem to circle back to imports always.

@wpferguson
Copy link
Member

I'm not exactly sure in which case the exif_read == FALSE code path should be triggered

Let's say I modify the exif information using a script (which I do sometimes) and I get it all screwed up. I can force the metadata to be reread, which cleans up my mess and sets the metadata in the database to agree with the metadata in the image.

@horazont
Copy link
Contributor Author

horazont commented Nov 4, 2025

@wpferguson As far as I can tell, that doesn't trigger an xmp read with exif_read == FALSE, but calls dt_exif_read which calls _exif_decode_xmp_data with exif_read set to TRUE.

(assuming you mean the "refresh EXIF" button)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants