If you want an open-source single-script solution, take a look at the textdeskew
script by Fred Weinhaus.
If you want to see what the script does: there are a few before-after figures on the page that I've linked to.
There are quite a few command line options, for fine-tuning.
Find it on Fred's ImageMagick Scripts for more, e.g. texctcleaner, also with ...
Looking at your requirements, there are some apps that are worth looking at:
Photoprism, demo is here.
Piwigo, demo is here.
I suggest trying out their demos, so that you can decide what works best for you.
There is also a comprehensive list here with other suggestions.
Edit: A more recent list of photo and video galleries.