waschinski / photo-stream

Self-hosted, super simple photo stream
https://github.com/waschinski/photo-stream
MIT License
448 stars 68 forks source link

Sort photos by MetadataDate #73

Closed nicosomb closed 1 year ago

nicosomb commented 1 year ago

Because I publish old photos on my website https://instantanes.loeuillet.org/, and because I want to display them at the first position of the list (last published, first in the list), I made a change in photo_filter.rb, to use MetadataDate (available in Exif values):

      sorted = photos.sort_by { |photo|
          Exiftool.new(photo.path)[:metadata_date]
      }

The RSS feed is also generated like that and that's fine for me.

I didn't have a look to make it cleaner (with a setting in .env) because I'm not a ruby expert. I just opened this issue to give you the idea 🙂

waschinski commented 1 year ago

Hi, you seem to know more about specific Exif values/tags than I do. So I assume date_time_original did not work for you? Which Exif values would make sense to get instead of getting all?

Btw I was playing around with setting a specific tag like so Exiftool.new(photo.path, '-TAG=MetadataDate') in order to increase performance but then it complains about Exiftool not being installed while it should be due to using the exiftool_vendored gem.

waschinski commented 1 year ago

Oh and I would probably convert this issue to a discussion if that's okay with you.

nicosomb commented 1 year ago

So I assume date_time_original did not work for you?

In fact, if today I publish a very old photo, the website visitors don't see the new picture quickly. I think it's better to display the last published photo at the top of the list.

date_time_original is very useful, I use it on photo detail to display the date of the photo. For example this photo https://instantanes.loeuillet.org/regard It was taken in 2008. The default behavior of photo-stream will display this photo at the end of the list. Not really practical for visitors (and the same for the RSS feed, which is used to tell "hey, there is a new photo, taken in 2008, but it's new on the website").

waschinski commented 1 year ago

Ah now I got you! What I still didn't get though is how MetadataDate does help with that unless you explicitly changed it to e.g. today.

And for what you would like to achieve I think even the fallback to the file system modified_time won't always work as that might not always be the time the file has been dropped to the original folder.