I once was complaining about nextcloud photo gallery and someone recommended Photorpism [1]. It has been day/night difference - I wanted a simple gallery that enables viewing my mess of unorganized photos. Yet, for it to be simple on UX, it had to be complex under the hood - has to self-organize based on metadata/AI, duplicate detection, generate thumbnails on his own, etc - and this is what Photoprism is.
Photoprism has superb performance - I have no lag going shifting through many, many photos.
Nextcloud lately upgraded their gallery, but it is still slow. It generates thumbnails on-the-fly. Maybe I can configure it somehow (I tried for v1 gallery but failed). Anyways, Photoprism is great and works out of the box. I like that I can select photos from different folders/views and do with selected photos something (like add to an album).
Moreover things works (Except delete, but archive is OK) for readonly volume, which is handy to mount nextcloud folder.
However a thing to note - you cannot use RPI4 with 2GB to use AI features - at least I had many other services running and RPI was lacking. But viewing photos was still good.
generating thumbnails on the fly doesn't have to be slow. It can be slow and often is as most implementation would rely on something like image magick or similar tool but you can get several order of magnitude faster if you go deeper.
I've spent a lot more time than I would dare to admit on that exact topic while working on my OSS project (https://github.com/mickael-kerjean/filestash) and I figured you could build tailored tool in C that rely on say libjeg and leverage very low level tricks like DCT scaling to do things much faster. Typically in Filestash creating a thumbnail takes about 15ms for a picture taken from my camera and it doesn't make a raspberry pi to break a sweat.