librephotos icon indicating copy to clipboard operation
librephotos copied to clipboard

Link photos from NextCloud

Open derneuere opened this issue 3 years ago • 18 comments

Currently, the Nextcloud Client downloads all the pictures into its own folder. r/selfhosted would like an option where the original photos are just linked and not downloaded. We would still create the thumbnails and create the tags, but when we open a picture a request goes to the Nextcloud server instead.

We use this client to download the images currently: https://github.com/owncloud/pyocclient

As I don't think we want to share all pictures via a public link, we want to save the information about the path within the photo. We need a new attribute "nextcloud_address", where we can save the server link and this would signify that the media is on a nextcloud server.

We would only download the image temporarily to create the thumbnails and read the metadata. This should be handled here and here.

We have to change all functions where an original is accessed. This would be currently on "saving metadata to disk / saving favorites" here and "download images" here. We would also need to redirect the request when accessing videos, because we read the original for that here.

derneuere avatar Dec 30 '20 17:12 derneuere

Great idea ! +1

thelittlefireman avatar Dec 30 '20 18:12 thelittlefireman

Another implementation idea:

Instead of copying, if the two apps live on the same computer then LibrePhotos should take the NextCloud location for photos. If not on the same computer, then get a link to NextCloud’s photo address.

derneuere avatar Dec 30 '20 19:12 derneuere

Is mounting librephotos data folder to nextcloud data folder working? Last time I tried it showed nothing in my admin page (there was no path to select).

sysoppl avatar Dec 30 '20 19:12 sysoppl

This would be great! A further extension would be to use Nextcloud's sharing/permission system to share albums in librephotos, but that would require two-way integration.

clawoflight avatar Jan 02 '21 11:01 clawoflight

I have Nextcloud and Librephotos running on the same machine. I've set the Librephotos photos directory to the photos directory of my Nextcloud data folder. It works but there's a number of reasons why I'm not a fan of this approach and I think something like this suggestion would really be a clean way to integrate the two services.

mike-lloyd03 avatar Mar 09 '21 00:03 mike-lloyd03

I think that the best practice to share files between multiple service is use file sharing like cifs, nfs or other network file system

tomamplius avatar Mar 09 '21 01:03 tomamplius

Best practice in what context? The issue here is that Nextcloud generally expects its data directory to not be modified externally. A network filesystem would not solve this problem (unless you set it up as an external storage provider in Nextcloud and moved all your photos there, but that comes with a bunch of other problems and limitations). In fact for this use case it would generally make things worse: more moving parts means more things to potentially break and impact performance, for no gain.

strugee avatar Mar 09 '21 01:03 strugee

Is there currently a recommended approach to pointing Librephotos to Nextcloud photos without having to duplicate the whole photo stash?

mike-lloyd03 avatar Mar 09 '21 01:03 mike-lloyd03

You can use mount.davfs on librephotos data folder

tomamplius avatar Mar 09 '21 02:03 tomamplius

I used efrecon/docker-webdav-client like this: https://gist.github.com/TheFehr/5329944b0130eb8aeb8e14c6d4577180 And seems to be working fine so far only set it up today. So there might be bugs I have not yet caught.

TheFehr avatar Mar 09 '21 15:03 TheFehr

@TheFehr Did this end up working well for you?

meichthys avatar Mar 06 '22 06:03 meichthys

I have not been using it very much after setting up.

I don't even have the containers up and running at the moment.

TheFehr avatar Mar 06 '22 06:03 TheFehr

Ok, thanks for the quick response. I'll give it a shot when i get a chance. Having the photos duplicated is chewing up a lot of storage and backup space!

meichthys avatar Mar 06 '22 06:03 meichthys

In case anyone else is wondering, the method described by @TheFehr in https://github.com/LibrePhotos/librephotos/issues/55#issuecomment-794065964 seems to work quite well. @TheFehr Thanks for providing the Gist. I had been trying to get that davclient container to work for weeks!

meichthys avatar Mar 08 '22 05:03 meichthys

I finally got the time to try @TheFehr's suggestion but besides getting the librephotos-docker_davmount_1 instance to run and see within at /mnt/webdrive the photos from my nextcloudURL WebDAV, I can't get them to be processed/linked to Librephotos... @meichthys: Is there anything else I might be missing? Thanks

munsuri avatar Apr 21 '22 23:04 munsuri

Got it working after I cleaned ./librephotos directory and restarted librephotos-docker_backend_1 when the message "No connection to backend, try again latter" was showing after several minutes. Once I was able to log in, selected data directory again, the photo processing started! Also, another observation, when changing nextcloudURL WebDAV in the .env file (and restarting the containers), librephotos didn't recognize any other picture, I had to again clean ./librephotos directory and start over.

munsuri avatar Apr 22 '22 10:04 munsuri

After testing for some days https://github.com/LibrePhotos/librephotos/issues/55#issuecomment-794065964, to me it seems to be quite slow: Screenshot 2022-04-24 173018

INFO:ownphotos:job 07c2cb52-...: geolocate: /data/imgs/IMG-20170730-WA0025.jpg, elapsed: 42.284343

INFO:ownphotos:job 07c2cb52-...: extract date time: /data/imgs/IMG-20170730-WA0025.jpg, elapsed: 84.896152

INFO:ownphotos:job 07c2cb52-...: add location to album dates: /data/imgs/IMG-20170730-WA0025.jpg, elapsed: 84.896853

INFO:ownphotos:job 07c2cb52-...: extract rating: /data/imgs/IMG-20170730-WA0025.jpg, elapsed: 123.172693

INFO:ownphotos:job 07c2cb52-...: extract video length: /data/imgs/IMG-20170730-WA0025.jpg, elapsed: 123.173287

INFO:ownphotos:job 07c2cb52-...: extract faces: /data/imgs/IMG-20170730-WA0025.jpg, elapsed: 123.611234

INFO:ownphotos:job 07c2cb52-...: image processed: /data/imgs/IMG-20170730-WA0025.jpg, elapsed: 123.645108

INFO:ownphotos:job 07c2cb52-...: handling image /data/imgs/IMG-20170730-WA0026.jpg

INFO:ownphotos:job 07c2cb52-...: generate thumbnails: /data/imgs/IMG-20170730-WA0026.jpg, elapsed: 0.237256

INFO:ownphotos:job 07c2cb52-...: calculate aspect ratio: /data/imgs/IMG-20170730-WA0026.jpg, elapsed: 0.263348

INFO:ownphotos:generated places365 captions for image /protected_media/thumbnails_big/154081351a3add7e57105ac3b8965a241.webp.

INFO:ownphotos:job 07c2cb52-...: generate caption: /data/imgs/IMG-20170730-WA0026.jpg, elapsed: 0.39006

INFO:ownphotos:job 07c2cb52-...: geolocate: /data/imgs/IMG-20170730-WA0026.jpg, elapsed: 44.677656

INFO:ownphotos:job 07c2cb52-...: extract date time: /data/imgs/IMG-20170730-WA0026.jpg, elapsed: 86.826832

INFO:ownphotos:job 07c2cb52-...: add location to album dates: /data/imgs/IMG-20170730-WA0026.jpg, elapsed: 86.827442

Fair to say that even though this time nextcloud and librephotos run in the same machine their network is independent (but it worked way faster with librephotos built-in Nextcloud scan support) . I might try to connect them locally if I run of out ideas as it will take too long to process all pics.

munsuri avatar Apr 24 '22 15:04 munsuri

@munsuri Thanks for following up with your observations. @derneuere Has there been any progress on linking to Nextcloud Photos in order to prevent duplication of the raw photos? Ive tried the alternatives but since i don't run Nextcloud & LibrePhotos on the same machine, the alternative options to duplicate photos is not very compelling.

meichthys avatar Jun 24 '22 03:06 meichthys

Is there currently a recommended approach to pointing Librephotos to Nextcloud photos without having to duplicate the whole photo stash?

I used symlinks.

simonSlamka avatar Sep 29 '22 09:09 simonSlamka

Is there currently a recommended approach to pointing Librephotos to Nextcloud photos without having to duplicate the whole photo stash?

I used symlinks.

This works well on a local machine, but many of us run nextcloud on a different machine.

meichthys avatar Sep 29 '22 11:09 meichthys