Nextcloud Photos offers seamless syncing capabilities, allowing you to access your photos from any device connected to your Nextcloud account.
With Nextcloud Photos, you can store an unlimited number of photos, making it an ideal solution for those with large collections.
Syncing is automatic, so you don't have to worry about manually transferring files between devices.
Nextcloud Photos can be used as a standalone service, hosting your photos on your own server, or as a supplement to existing cloud storage solutions.
Photos and Gallery
You can customize an album in the Gallery with a simple text file called gallery.cnf, which contains structured parameters with the Yaml markup language.
To enable global features, place the gallery.cnf file in your Nextcloud root folder, and you can have individual gallery.cnf files for each album if you want to define different behaviors in different albums.
Some things you can do with gallery.cnf include adding a link to a file that contains a description, writing a simple copyright statement directly in the configuration file, and defining the color of the background.
You can also define whether secondary albums will inherit the configuration, and it shows a button that allows you to choose which background to use, either black or white, for the image you are currently viewing (for images with transparent backgrounds).
Here are some features you can customize with gallery.cnf:
- Add a link to a file that contains a description.
- Write a simple copyright statement directly in the configuration file.
- Add a link to a file that contains a copyright statement.
- Define a type of order and order.
- Define the color of the background.
- Define whether secondary albums will inherit the configuration.
Photos can be easily synced with Nextcloud, and the app is available for Android phones. You can point it at the correct domain, tell it what to backup, and it's done!
Previews and Thumbnails
To optimize your Nextcloud photo gallery for smooth performance, let's tackle previews and thumbnails. Installing the Preview Generator app is the first step, which you can find in the Apps section under the Multimedia category.
This app will pre-generate previews on a regular basis, ensuring your photos are ready to view as soon as you open the folder. You can configure preview and thumbnail settings to balance resolution, performance, and storage usage.
To do this, SSH into your Nextcloud server and use the occ commands to set the default thumbnail sizes. The following settings provide a good balance for my environment: 32x32, 256x256, and 256 for width and height sizes.
You'll also need to edit your config.php file to specify the maximum preview size for images. This will affect the appearance and load time of images when you click on them. Add the following lines to the block: 'preview_max_x'=>'2048','preview_max_y'=>'2048','jpeg_quality'=>'60'.
To generate initial previews, run the following command in your terminal: `sudo-u www-data php /var/www/nextcloud/occ preview:generate-all -vvv`. This command can take a while to complete and use a lot of resources, so it's best to run it during a low-activity period.
Finally, add a cron job to continuously generate previews as new photos are added to Nextcloud. To avoid permissions problems, edit the crontab of the web server user and add the following line: `*/10 **** /usr/bin/php -f /var/www/nextcloud/occ preview:pre-generate`.
Here's a summary of the steps:
- Install the Preview Generator app.
- Configure preview and thumbnail settings using occ commands.
- Edit config.php to specify maximum preview size.
- Generate initial previews using the occ command.
- Add a cron job to continuously generate previews.
Photo Sorting
Sorting photos in Nextcloud can be a challenge, especially when it comes to chronological order. Nextcloud views files like your file system, but for photo albums, EXIF metadata is more relevant.
The EXIF data of a photo contains the original capture date, which is essential for sorting photos in chronological order. This is where exiftool comes in, a powerful command-line application that can read and manipulate EXIF data.
You can use exiftool to apply the original capture date to both the last modified attribute and the filename. This ensures that photos are displayed in chronological order, no matter how you sort them in Nextcloud.
There are two options for using exiftool: running a script from a synced client computer or running a script on the data directory on the server. Running it on the server has the advantage of automating periodic scans, but it may take longer depending on the server's speed.
If you choose to run the script on the server, you can automate periodic scans to keep your photos sorted and up-to-date.
Photo Editing
Photo editing is a crucial feature for many users. A full-blown photo editor was not a widely requested feature, but cropping and rotating pictures was a cumbersome process.
The implementation of this functionality was actually quite easy using the open source library called Filerobot Image Editor. This library made it possible to have a fully-fledged editor.
Gallery Settings:
Gallery settings are a crucial part of Nextcloud's gallery feature, allowing you to customize the behavior and appearance of your albums. You can create a gallery.cnf file in the Nextcloud root folder to define global characteristics, and individual gallery.cnf files for each album to define different behaviors.
One of the most useful features of gallery settings is the ability to add a link to a file that contains a description, which can be a great way to provide context for your photos. You can also write a simple copyright statement directly in the configuration file, or add a link to a file that contains a copyright statement.
You can customize the order of your photos by defining a type of order and order, which can be useful for creating a chronological or alphabetical order. Additionally, you can define the color of the background, which can help to create a consistent look and feel for your albums.
If you have multiple albums, you can define whether secondary albums will inherit the configuration from the primary album, which can save you time and effort. You can also create a button that allows you to choose which background to use, either black or white, for the image you are currently viewing (for images with transparent backgrounds).
Here are some of the key features you can customize in the gallery settings:
- Add a link to a file that contains a description.
- Write a simple copyright statement directly in the configuration file.
- Add a link to a file that contains a copyright statement.
- Define a type of order and order.
- Define the color of the background.
- Define whether secondary albums will inherit the configuration.
- Create a button to choose between black or white background for transparent images.
Maps
Maps are a fantastic feature in Nextcloud Photos, allowing you to visualize your photos on a map. This can be especially useful for travelers like myself who have photos from various locations.
To plot your photos on a map, you can use the Nextcloud App called Maps. However, I've had trouble getting it to work, so I'll be sure to update this if I'm able to fix it.
One approach to showing photos on a map is to cluster them client-side, but this can be inefficient with large photo libraries. Instead, clustering should be done on the server, preferably by the RDBMS itself. This is done by running a GROUP BY query on the division of the latitude/longitude by a fixed number, dividing the planet into progressively smaller sections inside the database.
As you zoom in on the map, you can adjust the size of the section to be smaller, showing more clusters of photos. However, this would require scanning over the entire database every time the user zooms in slightly or pans the map.
To resolve this, we can pre-cluster photos within a small radius, such as 30 meters, to reduce the overhead of querying the database. This way, when we do run the query, we can simply query the clusters instead of the photos.
Here are some ways to perform reverse geocoding, which is the process of looking up the name of the place where a photo was taken:
- LibrePhotos uses the Mapbox API, but this isn't an option since we need a completely free and private solution.
- PhotoPrism uses a special free API, but it has limitations that make it unsuitable.
- Immich uses the free Geonames dataset for reverse geocoding, but it requires a local-reverse-geocoder package.
Sync and Hosting
You can host Nextcloud yourself for improved privacy control over your data. Nextcloud is self-hosted, and I'm using DigitalOcean for hosting, which works fine on their cheapest droplet with Ubuntu 20.04.
DigitalOcean's cheapest droplet costs $5 and comes with 25GB of disk space. This isn't enough to store all my photos, so I'm using external storage called Spaces, which works similarly to Amazon's S3.
Choosing a Server Stack
Choosing a Server Stack is a crucial decision when setting up a Nextcloud server.
A good starting point is to consider the stack that has been proven to work well for others, like the author who successfully hosted a Nextcloud instance on the same VPS for 7 years.
To rebuild from scratch, modern tooling is a must.
The author rebuilt their Nextcloud instance from scratch, which suggests that upgrading to modern tooling can be beneficial.
Photo Sync
You can sync your photos with Nextcloud, a great alternative to Google Photos. I've personally found it to work well, uploading photos for a couple of weeks without any major issues.
The Nextcloud app on Android is easy to install and set up, simply point it at the correct domain and choose what to backup. It's also possible to resolve file name conflicts that can occur when editing photos.
One thing to note is that searching on Nextcloud isn't as good as Google Photos, but they're working to improve it. The app will let you know if there are any issues with uploading edited photos.
Hosting
To host Nextcloud, you need a server, and I've found that DigitalOcean's cheapest droplet with Ubuntu 20.04 works fine, costing just $5.
The droplet only comes with 25GB of disk space, so I'm using external storage to host all my photos and files, which DigitalOcean calls Spaces.
Spaces works similarly to Amazon's S3 and is a convenient option for storing large amounts of data.
Nextcloud needs some specific install changes to work with Spaces, which I'll cover in the next step.
Frequently Asked Questions
How do I automatically upload Photos to Nextcloud?
To automatically upload photos to Nextcloud, navigate to Settings > Automatic Upload and select the folder containing your photos. This will enable seamless syncing of your photos to your Nextcloud account.
Where are Nextcloud photos stored?
Nextcloud photos are stored in the data/ folder at the installation location. Check the Nextcloud documentation for more information on file storage and organization.
Sources
- https://varunpp2.medium.com/nextcloud-memories-putting-thousands-of-photos-on-the-world-map-1376cf4105a0
- https://rayagainstthemachine.net/linux%20administration/nextcloud-photos/
- https://nextcloud.com/blog/how-we-got-to-the-new-nextcloud-photos/
- https://www.btactic.com/how-to-configure-the-gallery-application-in-nextcloud/
- https://leavemealone.com/blog/moving-from-google-photos-to-nextcloud/
Featured Images: pexels.com