Feature request - add $(FILE_SIZE) as variable
Is your feature request related to a problem? Please describe.
I have a large collection of images taken in various formats (including several hundred scans from transparencies) over many years which I'm trying to organise. When looking at either identical or visually very similar images it's important for me to be able to quickly see which is the largest file size so that I can keep it and delete the others.
Describe the solution you'd like
It would be extremely useful if a variable $(FILE_SIZE) could be implemented so that I can add this to the thumbnail tooltip variable string and see at a glance which of two or more files is largest. Thanks!
Alternatives
Additional context
Well this is non trivial as the size of the image is currently not known from dt. We would need to get it at import time and add it into the database.
@wpferguson : Maybe a Lua script could do that?
@TurboGit either your ESP is working overtime, or mine is.
For the last week or so I've been trying to figure out a solution to adding image metadata fields that doesn't
- take 6 months to get released
- take hundreds of lines of code
- clutter up the database with all kinds of maker specific features
This kind of fits right in there.
Off the top of my head we could
- run on import, or by shortcut (to process already existing collections)
- attach a tag to the image like
metadata|file size|<size in ?>
That way you could use the tag in variable substitution, or to sort on in the collections module
Thanks for your answers. I'm afraid I'm not a programmer (I'm an artist) so your responses are a bit 'opaque' to me. :) But that sounds ideal if it's possible. Mostly I would be into processing existing collections as most of that work is already done but it's also useful when adding images of course.
I'm not sure if a tag would work here as we want to select all files whose size is less than some value.
I missed the part about the tooltip. Thinking....
I'm not sure if a tag would work here as we want to select all files whose size is less than some value.
If I understand you correctly this is not really the case. No 'action' as such is required just the size information displayed. All I want is to know the size (at a glance if possible). The selection decision can then be left up to me. I mean, it would be great if a 'deduplicate' module could identify the largest of a set of identical/visually similar images and delete the rest but that seems too much to ask for.
Thanks again for your interest in this!
I'll play and see with I can come up with :grin:
Like this?
I attached a tag to the image, metadata|file_size|XXXXXK, then use the variable $(CATEGORY[1,metadata]) to display it. I want to tune a little bit and test on windows also.
EDIT: Played with the variables a little bit until I figured out how they worked.
If I attach a tag metadata|file size|20480K to an image I can get the 20480K to display with either $(CATEGORY[1,metadata]) or $(CATEGORY(0,metadata|file size]) of which the second would be better if we wanted to make more metadata categories. I also created a tag file size|20480K and that can be displayed with just the $(CATEGORY(0,file size])
EDIT 2: I hate windows! It's working on windows too as long as you don't have filenames with accented characters in them. Lua also can't convert number strings from the file system into actual numbers so the file size is in shown in bytes.
@wpferguson : At least there is this information in the thumbs, but as discussed earlier this won't help to select images whose size are less than some value.
Looks great to me! Personally I would prefer to see it in the format shown here (kb rather than bytes) but that's not a big deal.
(kb rather than bytes)
Me too, I just have to figure out a way around windows character encoding (but I have and idea).
this won't help to select images whose size
He's selecting groups of images based on appearance then using the tooltip to find the one he wants to keep. However, if we enhance the collection module so that we can click then shift-click or ctrl-click to add additional values from a tag then we could :grin:
He's selecting groups of images based on appearance then using the tooltip to find the one he wants to keep. However, if we enhance the collection module so that we can click then shift-click or ctrl-click to add additional values from a tag then we could 😁
Absolutely correct. I need something which is 'quick and dirty' to get through thousands of files as painlessly as possible.
Here's the script. Unzip it and place it in a folder under your lua-scripts folder (maybe my_stuff?). Start darktable and go to script manager, and enable the script. Go to preferences->shortcuts->Lua scripts and attach a keyboard shortcut to get file sizes and attach tags.
At this point...
- if you go into a directory|folder|filmroll and use the shortcut all the images will have their size added as a tag
- if you import files, they will automatically be tagged with their size after import
- size defaults to megabytes to 2 decimal places. You can change to kilobytes to 1 decimal place in preferences->Lua options
- the tag is
metadata|file size|XXXXXX. If you don't want to see the tag in the tagging module, you can hide it by prefixing the tag name withdarktableso the tag would bedarktable|metadata|file_size|XXXXX.darktabletags are hidden in the tagging module by default. - To change the tag name to whatever you want you can edit the script and find the line with
TAG_PREFIXin it and change it to what you desire. Just remember that whatever you change it to effects the variable name ($CATEGORY[tagname,0])) where tagname ismetadata|file sizeor whatever you changed it to.
Wow! Thank you so much for doing that! It will make this mammoth task easier for sure. For a non programmer this seems like Gandalf level wizardry! I'm away now to play with it. Thank you again!
You're welcome. Let me know if there are any problems.
I'm probably just displaying my ignorance but I can't get it to work. I have followed the instructions for installing the LUA and setup a shortcut. I have enabled file_size_variable in the LUA list. I invoke the shortcut on a group of images.
Here's what I've written in the thumbnail extended overlay.
But what appears is this.
Could you let me know what I'm doing wrong? Thanks
it should be $(CATEGORY([metadata|file size,0])
Sorry to need hand-holding but it's still not working:
It would probably help if I told you the correct way...
$(CATEGORY[0,metadata|file size])
You can double check to make sure the file size got generated by opening the tagging module and hovering over an image and it should show the tag
I did that and now I'm getting a blank where the number should be. There is no number when I open the tagging module and hover over an image. Perhaps I should start again from scratch?
There is no number when I open the tagging module and hover over an image. Perhaps I should start again from scratch?
Well, we are making progress. You assigned the shortcut. Once you had done that, did you use the shortcut to force the file size tags to be generated?
Yes, but it didn't work. I tried disabling and re-starting 'file_size_variable' and that didn't work either. I also tried importing a new file but it wasn't assigned to that either. Sorry for being such a dunce!
So that means something is going wrong with the code.
What operating system are you on?
OS X. Tahoe 26.1 (the latest I think)
Can you run darktable in a terminal with the -d lua flag? That should show any errors.
EDIT: darktable should be at /Applications/darktable.app/Contents/MacOS/darktable so you should be able to run it with
/Applications/darktable.app/Contents/MacOS/darktable -d lua
It may or may not be relevant but all my images are stored on an external SSD drive...
Trigger the shortcut and let's see what the log shows then
That's odd - it's saying that there is no such file or directory. I've checked and the path is definitely correct and the files are definitely there.
The actual path is Volumes/Allpics/Allpics 20251114/ Is it the space in Allpics 20251114 that's causing the problem?