photoprism-fix/README.md
2024-11-05 14:20:22 -08:00

1.7 KiB

photoprism-fix

A set of scripts I've written to fix some issues with my Photoprism instance.

The problem

My NAS app would upload all mobile photos to the same directory, so it was messing up the names of files. If I had an image named IMG_1234.heic on my phone and another image with the same name on my wife's phone, the second image would get written as IMG_1234-Copy(1).heic. This was causing Photoprism to think the files were stacks of images and not showing them correctly. This was further complicated for live photos, where the video and image would be expected to have the same name, but may not.

The solution

My solution is to export all files from my phone directly, delete them from Photoprism, and then re-import them. This is not quite straightforward, as I have to make sure that I don't lose any favorites metadata. I also have to make sure that I don't delete files that didn't come from my phone.

The scripts

save-albums.py

This script downloads all favorited photos and stores them in a json file by hash. I am using this so that I can restore my favorites after I delete and re-import my libarary.

delete-replacements.py

This script assumes there is a directory with newer versions of files that you'd like to replace older ones with. It will delete any files in the old library that have a version in the newer library. By default, it will use sha1 hashes to compare files. If you add the --use-image-hash flag, it will use a phash of images and, for videos, a phash of the first frame.

hardlink.py

Recursively hardlink files between two directories. This is useful for when I need multiple attempts of importing and don't want to waste space or time making a full copy of thousands of files.