RupertAvery / DiffusionToolkit

Metadata-indexer and Viewer for AI-generated images
MIT License
709 stars 44 forks source link

[Feature request] Sort by date modified #204

Closed maxwell1755 closed 4 months ago

maxwell1755 commented 5 months ago

Is your feature request related to a problem? Please describe. Since most of my images were made on a mobile device, I had to FTP them to my PC. This overwrites the date created, but preserves the date modified. Since DiffusionToolkit only supports date created at the moment, this means my images are all in a random order.

Describe the solution you'd like An option in the "Sort by:" field for date modified.

Describe alternatives you've considered I've looked into modifying the date created to match the date modified in batch, but this seems to be more difficult than expected. using USB to transfer the images takes too long because the type-c port on my phone is too slow.

jonk999 commented 5 months ago

While waiting for a fix, you can create a copy of your DB and try the following if you like. I needed to update the created date on quite a few images. Note that it appears as though the created date in the program is the date the picture was added to the DB, not the date of the picture creation itself. I have noticed this as I add generations to the program usually the day after I generate them and they are in folders named the date I generated them. Edit: Regarding comments about file creation date the program uses, forgot I copy files to another folder the day or so after and so creation date of imported images would change.

In a SQL DB browser (I use SQLiteDatabaseBrowserPortable) open your backed up database. Dates aren't stored in regular format so you need to convert it to the correct format using the following: SELECT (CAST((((JulianDay('<year>-<month>-<date> <hr>:<min>:<sec>') - 2440587.5)*86400.0) + 62135596800) * 10000000 AS BIGINT)) Make a note of the result.

Look through your database Image table and make a note of the ID numbers of the images you want to give the value found above. Then run the following:

UPDATE Image
SET CreatedDate = '<number>'
Where Id between <first image> and <last image>;
is the value you got from the first part and and is the ID number range from the Image table. Not sure how helpful this is as it will depend largely on how many images you need to update. I also keep my images in folder using the date they were created - eg 2024-01-02 contains the images I want to keep generated on that date. I don't store/retain every image I generate. Perhaps a bit of double handling as I could just remove them from the image generation folder as I do everything locally.
RupertAvery commented 5 months ago

I use File.GetCreationTime to set the CreatedDate, so I'm getting the value reported by the filesystem, not the current date that I am adding the file.

     CreatedDate = File.GetCreationTime(file.Path),
jonk999 commented 5 months ago

I use File.GetCreationTime to set the CreatedDate, so I'm getting the value reported by the filesystem, not the current date that I am adding the file.

     CreatedDate = File.GetCreationTime(file.Path),

Ah my bad. Forgot I copy the images to another folder the day after creation and it's that folder that the program scrapes. My apologies!

RupertAvery commented 4 months ago

This should be implemented in the latest version