Skip to content

Add capture month to collection and collection filters#20697

Merged
TurboGit merged 6 commits intodarktable-org:masterfrom
da-phil:add_capture_month_to_collection_and_collection_filters
Apr 4, 2026
Merged

Add capture month to collection and collection filters#20697
TurboGit merged 6 commits intodarktable-org:masterfrom
da-phil:add_capture_month_to_collection_and_collection_filters

Conversation

@da-phil
Copy link
Copy Markdown
Contributor

@da-phil da-phil commented Mar 28, 2026

This PR adds the photo capture month to the "collections" and "collection filters" widgets, as requested on pixls: https://discuss.pixls.us/t/filtering-collection-on-capture-date-but-by-month-only/51621

This will enable users to better filter and analyze their photos based on the time of capture.
My typical use-case for this is finding suitable calendar pictures, given that I want them being taken in the same month as they should appear in the calendar.

Screenshot from 2026-03-28 23-59-08

A typical example for me is finding winter pictures, where I just want to filter for photos taken in December, January and February:
image

I have the following question to reviewers and other users:
Do you think we need the names of the months in there, or would numbers 00-12 be sufficient, given the necessity to translate those month names and their 3 character abbreviations?

Disclaimer: this code was co-created with Claude.

This commit adds a new field to the collection structure
to capture the month of photo capture.
It also updates the collection filters to allow filtering
based on the capture month. This will enable users
to better organize and analyze their photos based on the
time of capture.
@wpferguson
Copy link
Copy Markdown
Member

You need to add DT_COLLECTION_MONTH_PROP to the Lua enums at the end of src/collect.c

@ralfbrown ralfbrown added feature: enhancement current features to improve scope: DAM managing files, collections, archiving, metadata, etc. labels Mar 29, 2026
@da-phil
Copy link
Copy Markdown
Contributor Author

da-phil commented Mar 29, 2026

Thanks for the initial review @wpferguson @ralfbrown @TurboGit. Will address them once I'm getting back to the code.

Until then I have the following general question to you:
Do you think we need the names of the months in there, or would numbers 00-12 be sufficient, given the necessity to translate those month names and their 3 character abbreviations?

@TurboGit
Copy link
Copy Markdown
Member

Do you think we need the names of the months in there

I think it is fine to have the months name here. Those could be reused anyway in other contexts.

@da-phil da-phil force-pushed the add_capture_month_to_collection_and_collection_filters branch from 9e75167 to ed1c869 Compare March 29, 2026 21:09
@da-phil da-phil marked this pull request as ready for review March 31, 2026 22:42
@TurboGit TurboGit added this to the 5.6 milestone Apr 2, 2026
@da-phil da-phil force-pushed the add_capture_month_to_collection_and_collection_filters branch from 408e1dc to c4c60f3 Compare April 2, 2026 21:45
@wpferguson
Copy link
Copy Markdown
Member

Tested, works with Lua

@da-phil
Copy link
Copy Markdown
Contributor Author

da-phil commented Apr 3, 2026

I just completed some intensive testing with both "collections" and "collection filters" without encountering any issue or regression. Is there anything specific I shall watch out for?

@wpferguson
Copy link
Copy Markdown
Member

Just tested. Lua is broken.

    35.5954 LUA ERROR: dtutils.lua: prequire: 223: Error loading test_scripts/test_month_collection 
    35.5958 LUA ERROR: dtutils.lua: prequire: 224: Error returned is luaA_enum_to: Enum 'dt_collection_properties_t' field 'DT_COLLECTION_PROP_MONTH' not registered! 
    35.5962 LUA ERROR: script_manager.lua: activate: 543: error loading test_scripts/test_month_collection 
    35.5966 LUA ERROR: script_manager.lua: activate: 544: error message: luaA_enum_to: Enum 'dt_collection_properties_t' field 'DT_COLLECTION_PROP_MONTH' not registered! 

@da-phil
Copy link
Copy Markdown
Contributor Author

da-phil commented Apr 3, 2026

Just tested. Lua is broken.

    35.5954 LUA ERROR: dtutils.lua: prequire: 223: Error loading test_scripts/test_month_collection 
    35.5958 LUA ERROR: dtutils.lua: prequire: 224: Error returned is luaA_enum_to: Enum 'dt_collection_properties_t' field 'DT_COLLECTION_PROP_MONTH' not registered! 
    35.5962 LUA ERROR: script_manager.lua: activate: 543: error loading test_scripts/test_month_collection 
    35.5966 LUA ERROR: script_manager.lua: activate: 544: error message: luaA_enum_to: Enum 'dt_collection_properties_t' field 'DT_COLLECTION_PROP_MONTH' not registered! 

How can I reproduce your test?

@wpferguson
Copy link
Copy Markdown
Member

Here's the script,

test_month_collection.lua.txt

create a new directory in your lua scripts named test (or whatever) and drop the script in there after removing the .txt extension. When you start it, it will filter for images taken in April. Stop it before you exit, so that it doesn't try and start again when you start darktable.

The issue is at the end of src/libs/collect.c where the Lua enums are declared. Somehow it got lost in your latest round of changes/testing.

@da-phil
Copy link
Copy Markdown
Contributor Author

da-phil commented Apr 3, 2026

Thanks, I can now reproduce the same error, but only while I was running a darktable binary w/o this change. With this change it works.

The issue is at the end of src/libs/collect.c where the Lua enums are declared. Somehow it got lost in your latest round of changes/testing.

Hmmm, it is still there:
https://github.com/darktable-org/darktable/pull/20697/changes#diff-2c4ad8c3aa04d783a05735ec0fbeb46a420d90c81153134287e320ff0a52f36bR4066

@wpferguson
Copy link
Copy Markdown
Member

wpferguson commented Apr 3, 2026

Oops, maybe my error... Testing too may collection PRs....

EDIT: It works correctly. Sorry for the noise.

Copy link
Copy Markdown
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, code ok now. Thanks!

@TurboGit TurboGit merged commit 228c7d8 into darktable-org:master Apr 4, 2026
5 checks passed
@da-phil da-phil deleted the add_capture_month_to_collection_and_collection_filters branch April 4, 2026 15:05
@MStraeten
Copy link
Copy Markdown
Collaborator

this breaks old filmroll sort by folder.
instead of the folder now just the shown subfolders are taken into account for sorting.

now if 2 levels are selected and order by folder
/volumes/aa/2010 and /users/bb/2012 are sorted as
aa/2010
bb/2012

instead of former
bb/2012
aa/2010
which took the whole folder path into account

@da-phil
Copy link
Copy Markdown
Contributor Author

da-phil commented Apr 4, 2026

this breaks old filmroll sort by folder. instead of the folder now just the shown subfolders are taken into account for sorting.

now if 2 levels are selected and order by folder /volumes/aa/2010 and /users/bb/2012 are sorted as aa/2010 bb/2012

instead of former bb/2012 aa/2010 which took the whole folder path into account

Ups, sorry, I have never used filmrolls before, hence it slipped through.
I'll take a quick look and see if I can fix it, if not, we can revert the PR for the time being.

@da-phil
Copy link
Copy Markdown
Contributor Author

da-phil commented Apr 4, 2026

@MStraeten I cannot reproduce and I'm not sure if my changes have any influence on filmroll sorting.
Are you sure that this change was not done by #20718 which was also merged a couple of hours ago?

@da-phil
Copy link
Copy Markdown
Contributor Author

da-phil commented Apr 4, 2026

The issue seems to be in _sort_filmroll_rows at collect.c:167-172. It was sorting by ra->folder which is the truncated display name (only the last N folder levels from dt_image_film_roll_name(), instead of the full path stored in ra->value.

With show_folder_levels set to 2:

/volumes/aa/2010 → display name aa/2010
/users/bb/2012 → display name bb/2012

Sorting by the display names gives aa/2010, bb/2012, but sorting by the full paths gives /users/bb/2012, /volumes/aa/2010 — the old behavior you expected.

Does the following patch help?

diff --git a/src/libs/collect.c b/src/libs/collect.c
index 139f9b2cc0..f2aac24254 100644
--- a/src/libs/collect.c
+++ b/src/libs/collect.c
@@ -168,7 +168,7 @@ static gint _sort_filmroll_rows(gconstpointer a, gconstpointer b)
 {
   const filmroll_row_t *ra = a;
   const filmroll_row_t *rb = b;
-  return g_ascii_strcasecmp(ra->folder, rb->folder);
+  return g_ascii_strcasecmp(ra->value, rb->value);
 }

@MStraeten
Copy link
Copy Markdown
Collaborator

sorry, you're right, i haven't seen the other collection affecting merge -
the patch just repairs the order, but the i'ts not possible to reverse the sorting.

@MStraeten
Copy link
Copy Markdown
Collaborator

i will file an issue for that so it can be properly tracked ...

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

Labels

feature: enhancement current features to improve scope: DAM managing files, collections, archiving, metadata, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants